Question

In: Computer Science

Design a program which a census the numbers and percentages of houses with particular numbers of...

Design a program which a census the numbers and percentages of houses with particular numbers of occupants in a road. The output must appear in a table like the one below:

Output

Occupants 0 1 2 3 4 5 6 >6 No.

houses 2 3 7 9 6 4 2 2

Percentage 5.7% 8.6% 20.0% 25.7% 17.1% 11.4% 5.7% 5.7%

Houses with more than 6 occupants are considered to be overcrowded, and are to be output under a single column (>6). The data input part of the program must request the number of houses for each occupancy category. For example, the program should ask similar questions:

Provide the number of houses with 0 occupancy: 2

Provide the number of houses with 1 occupancy: 3

Provide the number of houses with 2 occupancy: 7

Provide the number of houses with 3 occupancy: 9

Provide the number of houses with 4 occupancy: 6

Your program should ask the user 8 times about houses with occupancy of 0 to 7 to count the numbers of houses with particular numbers of occupants. Each count should be stored in a separate variable. For each question, the user of the program should input numbers of houses with a particular occupancy value. After the program ask for the number of houses with occupants > 6, the program should output a table like the one above, and then exits. The table above is a result from inputting a value for the number of houses with different occupancy settings in a street with total of 35 houses. The last raw of the table reflects the percentage of each houses of different occupancy level given the total number of houses in the street. For example, the percentage of houses with 0 occupancy is 5.7%. This is because (2/35) * 100 is 5.7 %

Solutions

Expert Solution

Program written in c++ programming language

program:

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
//initializing the variable
float percent[20],percentage,num;
int i,occup[20];

//using loop to enter number of houses with respectuve occupancy
for(i=0;i<=7;i++){
printf("Provide the number of houses with %d occupancy:",i);
scanf("%d",&occup[i]);
num=occup[i];
percentage=(num/35) * 100; // calculating the percetage
percent[i]=percentage;
}
  
printf("Occupants 0 1 2 3 4 5 6 >6 No" );
printf("\nhouses ");
for(i=0;i<=7;i++){
printf("%d ",occup[i]); // printing number of houses
}
printf("\nPercentage ");
for(i=0;i<=7;i++){
printf("%0.1f%% ", percent[i]); // printing percetnage

}

}

output:

Provide the number of houses with 6 occupancy:2                                                                                                        

Provide the number of houses with 7 occupancy:2                                                                                                        

Occupants 0 1 2 3 4 5 6 >6 No                                                                                                                          

houses 2 3 7 9 6 4 2 2                                                                                                                                 

Percentage 5.7% 8.6% 20.0% 25.7% 17.1% 11.4% 5.7% 5.7%  

Refer this screen shoot of the program for better understanding

output:


Related Solutions

Design a modular program which asks the user to enter a list of numbers. The numbers...
Design a modular program which asks the user to enter a list of numbers. The numbers must be stored in an array. The program then finds the index of the first occurrence of the smallest element in the array and the last occurrence of the largest element in the array. The program displays the position and value of each of these items.
(JAVA) Implementing a Program Design a program that prompts the user for twenty numbers. If the...
(JAVA) Implementing a Program Design a program that prompts the user for twenty numbers. If the number is positive, then add the number to the current sum. If the number is negative, then subtract the sum by one. Implement just the main method. Assume that all libraries are imported, and class has been declared.
A recent census report indicated the following percentages for methods of commuting to work for workers...
A recent census report indicated the following percentages for methods of commuting to work for workers over 15 years of age: 76.6% drive alone, 9.7% carpool, 4.9% use public transportation, 2.8% walk, 1.7% use other forms of transportation, 4.3% work at home. A random sample of workers yielded the following table of observed methods of commuting to work. Method Alone Carpool Public Walk Other Home Observed 355 65 30 20 10 20 Is there sufficient evidence to conclude that the...
Design a simple calculator program using C++ which is able to: 1. ADD two decimal numbers...
Design a simple calculator program using C++ which is able to: 1. ADD two decimal numbers 2. MULTIPLY two decimal numbers. The following features must be incorporated in your program. 1. Must have an interface for the user to be able to either select the ADD option or MULTIPLY option or to EXIT the program. NOTE: If the user makes a wrong selection, a display must be shown to inform the user and the user must be given a choice...
Design the logic for a program that allows a user to enter 20 numbers, then displays...
Design the logic for a program that allows a user to enter 20 numbers, then displays them in the reverse order of entry. Design the logic for a program that allows a user to enter 20 numbers, then displays each number and its difference from the numeric average of the numbers entered. The program is C++. I need a Pseudocode
Design a program that will ask the user to input two integer numbers and then perform...
Design a program that will ask the user to input two integer numbers and then perform the basic arithmetic operations such as addition and subtraction. Each calculation is done by a separate function. The main function gets the input from the user, then calls the addition function and the subtraction function one at a time to perform the calculations. Each calculation function (addition or subtraction function) performs an arithmetic operation and then returns the calculation results back to where it...
Design a complete program that asks the user to enter a series of 20 numbers. The...
Design a complete program that asks the user to enter a series of 20 numbers. The program should store the numbers in an array and then display each of the following data: I. The lowest number in the array II. The highest number in the array III. The total of the numbers in the array IV. The average of the numbers in the array *PYTHON NOT PSUEDOCODE AND FLOW CHART!!!!*
The U.S. Census Bureau announced that the mean sale price of new houses sold in 2011...
The U.S. Census Bureau announced that the mean sale price of new houses sold in 2011 was $267,900. Assume that the standard deviation of the prices is $90,000. (a) If you select a random sample of n = 100, what is the probability that the sample mean will be less than $300,000? (b) If you select a random sample of n = 100, what is the probability that the sample mean will be between $275,000 and $290,000? (c) Between what...
The U.S. Census Bureau announced that the mean sales price of new houses sold in 2016...
The U.S. Census Bureau announced that the mean sales price of new houses sold in 2016 was $370,800. Suppose the sales price follows a normal distribution with a standard deviation of $90,000. a. (5 points) If you select samples of n = 4, what is the standard error of the mean? b. (5 points) If you select samples of n = 100, what is the standard error of the mean? c. (5 points) If you select a random sample of...
Python Programming Question: Objective: Sum of Numbers. Design a program with a loop that asks the...
Python Programming Question: Objective: Sum of Numbers. Design a program with a loop that asks the user to enter a series of positive numbers. The user should enter "0" (zero) to signal the end of the series. After all the positive numbers have been entered, the program should display their sum. The program should display the following: • Contain proper indentation. • Comments (Blocks or Lines). • Good Variables initializations. • Good questions asking for the parameters of the code....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT