This is a computer science II Java coding question- please read the instructions and use the pre-written
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Using a Bubble Sort in Java m E Using a Bubble Sort Summary In this lab, you complete a Java program that uses an array to store data for the village of Marengo. The program is described in Chapter 8, Exercise 5, in Programming Logic and Design. The program should allow the user to enter each household size and determine the mean and median household size in Marengo. The program should output the mean and median household size in Marengo. The file provided for this lab contains the necessary variable declarations and input statements. You need to write the code that sorts the household sizes in ascending order using a bubble sort and then prints the mean and median household size in Marengo. Comments in the code tell you where to write your statements. Instructions HouseholdSize.java 1 // HouseholdSize.java - This program uses a bubble sort to arrange up to 300 household sizes in 2 // descending order and then prints the mean and median household size. 3 // Input: Interactive. 4 // Output: Mean and median household size. 5 6 import java.util.Scanner; 7 8 public class HouseholdSize 9 { 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 public static void main(String args[]). { Scanner s = new Scanner(System.in); // Declare variables. final int SIZE = 300; // Maximum number of household sizes. int householdSizes[] = new int[SIZE]; // Array used to store up to 300 household sizes. int x; int limit= SIZE; int householdSize = 0; String householdSizeString; int pairsToCompare; lean int temp; double sum = 0; double mean = 0; double median = 0; urred; // Input household size Using a Bubble Sort in Java m E Using a Bubble Sort Summary In this lab, you complete a Java program that uses an array to store data for the village of Marengo. The program is described in Chapter 8, Exercise 5, in Programming Logic and Design. The program should allow the user to enter each household size and determine the mean and median household size in Marengo. The program should output the mean and median household size in Marengo. The file provided for this lab contains the necessary variable declarations and input statements. You need to write the code that sorts the household sizes in ascending order using a bubble sort and then prints the mean and median household size in Marengo. Comments in the code tell you where to write your statements. Instructions HouseholdSize.java 1 // HouseholdSize.java - This program uses a bubble sort to arrange up to 300 household sizes in 2 // descending order and then prints the mean and median household size. 3 // Input: Interactive. 4 // Output: Mean and median household size. 5 6 import java.util.Scanner; 7 8 public class HouseholdSize 9 { 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 public static void main(String args[]). { Scanner s = new Scanner(System.in); // Declare variables. final int SIZE = 300; // Maximum number of household sizes. int householdSizes[] = new int[SIZE]; // Array used to store up to 300 household sizes. int x; int limit= SIZE; int householdSize = 0; String householdSizeString; int pairsToCompare; lean int temp; double sum = 0; double mean = 0; double median = 0; urred; // Input household size
Expert Answer:
Answer rating: 100% (QA)
HouseholdSizejava import javautilScanner public class HouseholdSize public static vo... View the full answer
Related Book For
Posted Date:
Students also viewed these algorithms questions
-
The job order cost sheets for Nashville Inc., show the following information about special orders for June and July of the current year: The company prices its jobs to make a 50 percent gross profit...
-
Write a char-converter program that accepts a single line of text from the user and converts Turkish characters to English ones. Check the text character by character using a for-loop. Sample...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
What did Frederick Taylor, the proponent of scientific management, advocate for to achieve efficiency in manufacturing?
-
Prepare a comparative common-size income statement for Wolf Corporation. To an investor, how does 2017 compare with 2016? Explain your reasoning. Wolf Corporation Income Statement For the Years Ended...
-
In the following data, X is the Fahrenheit temperature and Y is the number of times a cricket chirps in 1 min (see Problem 3, Section 4.2). In Problems 6-12, construct a scatterplot of the given...
-
Which statement is false with respect to Section 404 of SOX? a. The section requires management's assessment of internal control over financial reporting. b. The auditor's report on internal control...
-
Simonsen Village is a relatively new community. At the start of the year, the government had no long-term assets or liabilities. In fact, all of the infrastructure (e. g., roads) in the village are...
-
please solve. 1. This question is about fixed income securities and stocks [25 marks] Use discrete compounding of interest rates and assume that bond coupons are annual throughout this question. a)...
-
Cody Jenkins and Lacey Tanner formed a partnership to provide landscaping services. Jenkins and Tanner shared profits and losses equally. After all the tangible assets have been adjusted to current...
-
INPUT DATA (Totals in Millions): KEY OUTPUT: Stock price (Po) $30.50 Debt: Earnings per share (EPSO) $2.30 YTM Last dividend (Do) $0.46 YTC Analysts "L-R" growth rate 16.00% Payout ratio (PO) 20.00%...
-
In words, define the random variable X. The Ice Chalet offers dozens of different beginning iceskating classes. All of the class names are put into a bucket. The 5 P.M., Monday night, ages 8 to 12,...
-
What would happen to the confidence interval if the level of confidence were 95%? A poll of 1,200 voters asked what the most significant issue was in the upcoming election. Sixty-five percent...
-
Which distribution should you use for this problem? A poll of 1,200 voters asked what the most significant issue was in the upcoming election. Sixty-five percent answered the economy. We are...
-
The 92% confidence interval is _______. The Ice Chalet offers dozens of different beginning iceskating classes. All of the class names are put into a bucket. The 5 P.M., Monday night, ages 8 to 12,...
-
Calculate the following: a. lower limit b. upper limit c. error bound The Ice Chalet offers dozens of different beginning iceskating classes. All of the class names are put into a bucket. The 5 P.M.,...
-
Imagine you were to invest $1400 in your Roth IRA retirement account at the beginning of every year. If you do this for 40 years and the investment earns 9% interest compounded annually. How much...
-
If a and b are positive numbers, find the maximum value of f ( x ) = x a (9 x ) b on the interval 0 x 9.
-
Determine the normal force, shear force, and moment at a section passing through point C. Assume the support at A can be approximated by a pin and B as a roller. Units used: kip = 103 lb Given: F1 =...
-
The pole supports a traffic light of weight W. Using Cartesian vectors; determine the moment of the weight of the traffic light about the base of the pole at A. Given: W = 22 lb a = 12 ft θ =...
-
Cable BC exerts force F on the top of the flagpole. Determine the projection of this force along the z axis of the pole. Given: F = 28 N a = 12 m b = 6 m c = 4 m B F)
-
Calculate \(\frac{124}{297}+\frac{3}{125}\).
-
Express \(\frac{252}{840}\) in lowest terms.
-
Calculate \(\frac{21}{40}-\frac{8}{40}\).
Study smarter with the SolutionInn App