Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <conio>
- #include <fstream> //Needed to use files
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream inFile;
- int people;
- inFile.open("people.dat");
- inFile >> people;
- cout << people <<endl;
- inFile >> people;
- cout <<people <<endl;
- inFile >>people;
- cout <<people <<endl;
- inFile >>people;
- cout <<people <<endl;
- inFile >>people;
- cout << people <<endl;
- inFile >>people;
- cout <<people <<endl;
- inFile.close();
- getch();
- return 0;
- }
This program should produce a bar chart showing the population growth for a small town at 20 year intervals during the past 100 years (the years are from 1900-2000). This program should read in the population figures from a file (which is people.dat). For each year, it shoudl display the date and a bar consisting of one asterdisk for each 1000 people. For example:
1900 **
1920 ****
1940 *****
Here is the data from the file.
2000
4000
5000
9000
14000
18000
I am having trouble figuring how to read the file to get it to print out a star for each 1000 years.
Does anyone have any idea how to do that?