The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
In this lab, you will complete a Java program that uses an array to store data for the village of Marengo. The village of Marengo conducted a census and collected records that contain household data, including the number of occupants in each household. The exact number of household records has not yet been determined, but you know that Marengo has fewer than 300 households. 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.
1. Open the source code file named Householdsize.java using notepad or the editor of your choice.
2. Write the bubble sort.
3. Output the median household size in Marengo.
4. Save the source code file in the directory of your choice, and then make that directory your working directory.Â
5. Compile the source code file. Householdsize.java.Â
6. Execute the program with the following input, and output the household sizes: 4, 1, 2, 4, 3, 3, 2, 2, 2, 4, 5, 6.Â
Basically looking for help the bubble sort code. I have written the pseudocode but having trouble getting my compiler to work properly on this. This is my second to last assignment in this class. Looking for an A to help me get the rest of the way.Â
Â
Â
//******************************************************************************// TTILE:// FILENAME:// PREPARED FOR:// PROGRAMMER:// DEVELOPMENT DATE:// COMPILER USED:// TARGET PLATFORM://******************************************************************************import javax.swing.*;public class HouseholdSize{public static void main(String args[]){// Declare variables.final int SIZE = 300;// Maximum number of householdsizes.int householdSizes[] = new int[SIZE];// Array used to store up to300 household sizes.int x;int limit = SIZE;int householdSize = 0;String householdSizeString;int pairsToCompare;boolean switchOccurred;int temp;double sum = 0;double mean = 0;int median = 0;// Input household sizehouseholdSizeString = JOptionPane.showInputDialog("Enter householdsize or 999 to quit: ");householdSize = Integer.parseInt(householdSizeString);// This is the work done in the fillArray() methodx = 0;while(x < limit && householdSize != 999){// Place value in array.householdSizes[x] = householdSize;// Calculate total of household sizes herex++;// Get ready for next input item.householdSizeString = JOptionPane.showInputDialog("Enterhousehold size or 999 to quit: ");householdSize = Integer.parseInt(householdSizeString);}// End of input loop.// Find the mean// This is the work done in the sortArray() method// This is the work done in the displayArray() method// Print the mean// Calculate the median// Print the median
Attachments:
-----------