Engineering
Engineering, 23.03.2020 23:08, kragland4752

In this lab, you complete a C++ 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.1. Open the source code file named HouseholdSize. cpp using Notepad or the text editor of your choice.2. Write the bubble sort.3. Output the mean and median household size in Marengo.4. Save this source code file in a directory of your choice, and then make that directory your working directory.5. Compile the source code file HouseholdSize. cpp.6. Execute the program with the following input and record the output: Household sizes: 4, 1, 2, 4, 3, 3, 2, 2, 2, 4, 5, 6Here is the Householdsize. cpp file information:// HouseholdSize. cpp - 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.#include #include using namespace std;int main(){ // Declare variables. const int SIZE = 300; // Number of household sizes int householdSizes[SIZE]; // Array used to store 300 household sizes int x; int limit = SIZE; int householdSize = 0; int pairsToCompare; bool switchOccurred; int temp; double sum = 0; double mean = 0; int medianIndex = 0; // Input household size cout << "Enter household size or 999 to quit: "; cin >> householdSize; // Fill an array with household sizes - the maximum households = 300 x = 0; while(x < limit && householdSize != 999) { // Place value in array. householdSizes[x] = householdSize; // Calculate total of household sizes using the sum variable x++; // Get ready for next input item. cout << "Enter household size or 999 to quit: "; cin >> householdSize; } // End of input loop. // set the limit to x // calulate the mean household size by dividing the sum by the limit // Use one of your sort routines to sort the Array so that the house sizes are in ascending order // Print the mean // Set medianIndex = (limit-1)/2 // Print the median found at householdSizes[medianIndex] return 0;} // End of main function

answer
Answers: 2

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, koolgurl2003
Apump is used to circulate hot water in a home heating system. water enters the well-insulated pump operating at steady state at a rate of 0.42 gal/min. the inlet pressure and temperature are 14.7 lbf/in.2, and 180°f, respectively; at the exit the pressure is 60 lbf/in.2 the pump requires 1/15 hp of power input. water can be modeled as an incompressible substance with constant density of 60.58 lb/ft3 and constant specific heat of 1 btu/lb or. neglecting kinetic and potential energy effects, determine the temperature change, in °r, as the water flows through the pump.
Answers: 1
image
Engineering, 04.07.2019 19:10, gabigalvis1091
What is the main objective of using reheat rankine cycle?
Answers: 3
image
Engineering, 04.07.2019 19:10, kelseiroll9759
Ahelical coil spring has a mean diameter of 50 mm, a wire diameter of 5.5 mm and is wound with a pitch of 10 mm. the spring steel has an ultimate strength of 1250 mpa. find the force needed to compress the spring solid and the wire stress in this condition. state whether the spring will return to its initial length.
Answers: 1
image
Engineering, 04.07.2019 19:20, natalie2sheffield
Acompressor compresses a gas, a pump compresses a liquid. for a given pressure ratio, why does it take more work to compress a gas in a compressor than a liquid in a pump? a)- for a given pressure ratio the average specific volume for a gas is much higher than the average specific volume for a liquid. b)- there is no difference. the only difference is the amount of heat generated (not work) c)- for a given pressure ratio the average volurge for a gas is much higher than the average volume for a liquid. d)-there is no difference
Answers: 3
Do you know the correct answer?
In this lab, you complete a C++ program that uses an array to store data for the village of Marengo....

Questions in other subjects:

Konu
Mathematics, 07.07.2019 10:00
Konu
Biology, 07.07.2019 10:00