Question: write a program that produces a bar chart showing the population growth of praiereville, a small town in the midwest, at 20-year interval during the

write a program that produces a bar chart showing the population growth of praiereville, a small town in the midwest, at 20-year interval during the past 100 years. The program should read in the population figures(rounded to the nearest 1,000 people) for 1910,1930,1950,1970,1990,2010 from a file. For each year display the date and a bar consisting of one asterisk for each 1000 people. The data can be found in the People.txt file.

Here is an example of how the chart might began:

PRAIRIEVILLE POPULATION GROWTH

(each * represents 1000 people)

1910 **

1930 ****

1950 *****

the people text file has following data.

2000 4000 5000 9000 14000 18000 

Here is my code, what am i doing wrong?

#include

#include

#include

using namespace std;

int main()

{

ifstream inputFile;

int number,year = 1910;

inputFile.open("People.txt");

cout << "PRAIRIEVILLE POPULATION GROWTH" << endl;

cout << "(each * represents 1000 people)" << endl;

// Loop through all data found in People.txt file.

while (inputFile>>number&&year<2010)

{

cout << year << ": ";

for(int i=0;, i

cout<<"*";

year+=20;

cout<

}

system("Pause");

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!