// HouseholdSize.java - This program uses a bubble sort to arrange up to 300household sizes in// descending order and then prints the mean and median household size.// Input: Interactive.// Output: Mean and median household size.import java.util.Arrays;import java.util.stream.IntStream;import javax.swing.*;public class HouseholdSize {public static void main(String args[]) {// Declare variables.//f
...[Show More]
// HouseholdSize.java - This program uses a bubble sort to arrange up to 300
household sizes in
// descending order and then prints the mean and median household size.
// Input: Interactive.
// Output: Mean and median household size.
import java.util.Arrays;
import java.util.stream.IntStream;
import javax.swing.*;
public class HouseholdSize {
public static void main(String args[]) {
// Declare variables.
//final int SIZE = 300; // Maximum number of household
sizes.
int householdSizes[] = new int[300]; // Array used to store up to 300
household sizes.
int x;
//int limit = SIZE;
int householdSize;
String householdSizeString;
int pairsToCompare;
boolean switchOccurred;
int temp;
double sum = 0;
double mean = 0;
int median = 0;
// Input household size
householdSizeString = JOptionPane.showInputDialog("Enter household size
or 999 to quit: ");
householdSize = Integer.parseInt(householdSizeString);
// This is the work done in the fillArray() method
x = 0;
while (x < householdSizes.length && householdSize != 999) {
// Place value in array.
householdSizes[x] = householdSize;
// Calculate total of household sizes here
sum = IntStream.of(householdSizes).sum();
[Show Less]