Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ coding assignment: Population Bar Chart Write a program that produces a bar chart showing the population change of a town or city over a

C++ coding assignment:

image text in transcribed

image text in transcribed

Population Bar Chart Write a program that produces a bar chart showing the population change of a town or city over a period of time. The program will be reading in the population figures from a file. For each year it will output the date and a bar chart of asterisks so that one can visualize the change in population growth. This chart may be output to the screen but MUST be output to a file. Application Outline Welcome the user to your program (as usual). Ask them for the name of the city and whether they want each asterisk to represent 1,000 people, 10,000 people, or 100,000 people. (WARNING: City names can contain blank spaces. Because of this, the city must be read in using getline, not cin>>.) Your program then opens the input file, opens the output file, and then reads data and outputs the bar chart based on their preference. After closing the files, the application is finished. It is assumed that only one city's population chart will be created per program run The Input File The input file consists of lines of data. Each line has a year (an integer) and the population for that year (an integer), separated by a blank space. For example 1900 2224 1920 4628 1940 5305 You do not know ahead of time how many lines of data will be stored, so you must read data while not.eof (or while .good). YOU MUST have the user enter at least the file NAME (e.g., SeattleIn.txt) rather than coding this as a string in your program (and having to change program code in order to change the file name) Remember that you will need the full path in order to run the program (see class examples) The Output File The first line of the output file is a heading that includes the name of the city. The second line tells them how many people each asterisk represents (1,000 or 10,000 or 100,000). Each additional line has the year and 0 or more asterisks, depending on the population. We will not worry about "partial" asterisks, and you should truncate the population to the nearest 1000, 10000 or 100000. For example, if the data shown above for 1900, 1920 and 1940 were for the city of Pleasantburg with one asterisk representing 1,000 people Pleasantburg Population (each * represents 1000 people) 1900 * 1920 1940 **

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago

Question

5. If yes, then why?

Answered: 1 week ago

Question

3. What changes should I be making?

Answered: 1 week ago