Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions Ensure the file HouseholdSize.java is open. Write the bubble sort. Output the mean and median household size in Marengo import java.util.Scanner; public class HouseholdSize

Instructions

  1. Ensure the file HouseholdSize.java is open.
  2. Write the bubble sort.
  3. Output the mean and median household size in Marengo

import java.util.Scanner;

public class HouseholdSize

{

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;

boolean switchOccurred;

int temp;

double sum = 0;

double mean = 0;

double median = 0;

// Input household size

System.out.println("Enter household size or 999 to quit: ");

householdSizeString = s.nextLine();

householdSize = Integer.parseInt(householdSizeString);

// This is the work done in the fillArray() method

x = 0;

while(x < limit && householdSize != 999)

{

// Place value in array.

householdSizes[x] = householdSize;

x++; // Get ready for next input item.

System.out.println("Enter household size or 999 to quit: ");

householdSizeString = s.nextLine();

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

System.exit(0);

} // End of main() method.

} // End of HouseholdSize class.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

=+(16.32) 81(w) for w A and 0 Answered: 1 week ago

Answered: 1 week ago