Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

More Books

Students also viewed these Databases questions