1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
marishachu [46]
3 years ago
11

Write a program that produces a bar chart showing the population growth of Prairieville, a small town in the Midwest, at 20-year

intervals during the past 100 years. The program should read in the population figures for 1900, 1920, 1940, 1960, 1980, and 2000 from a file named People.txt. It is understood that the first value represents the population in 1900 (for example, 2,843), the second the population in 1920 and so on. For each year it should display the year, followed by at least one space followed by a bar consisting of one asterisk for each 1,000 people. (The program should round UP so that a population of 1 would generate one asterisk -- as would 1000, while a population of 1,001 would generate two, etc.)
Computers and Technology
1 answer:
Sunny_sXe [5.5K]3 years ago
5 0

Answer:

#include <iostream>

#include <fstream>

using namespace std;

int main()

{

ifstream Inputfile;

Inputfile.open("People.txt"); // Open file

if (!Inputfile) // Test for open errors

{

cout << "Error opening file.\n";

return 0;

}

int Pop; // Population

// Display Population Bar Chart Header

cout << "PRAIRIEVILLE POPULATION GROWTH\n"

<< "(each * represents 1000 people)\n";

for (int Year = 1; Year <= 6; Year++)

{ // One iteration per year

switch (Year)

{

case 1 : cout << "1900 ";

break;

case 2 : cout << "1920 ";

break;

case 3 : cout << "1940 ";

break;

case 4 : cout << "1960 ";

break;

case 5 : cout << "1980 ";

break;

case 6 : cout << "2000 ";

break;

}

Inputfile >> Pop; // Read from file

// calculate one per 1000 people

//cout<<"**"<<Pop<<endl;

while(Pop > 0)

{ // Display one asterisk per iteration

// One iteration per 1000 people

cout << "*";

Pop -= 1000;

}

cout << endl;

}

Inputfile.close(); // To close file

return 0;

}

Explanation:

You might be interested in
The primary reason for a company to outsource jobs is to
DedPeter [7]
The primary reason is to cut labor costs
7 0
4 years ago
Read 2 more answers
If your computer will not turn on, What is something you can would you use to diagnose the problem?
inysia [295]
3. See if its plugged in
3 0
3 years ago
Read 2 more answers
All it services and servers are equally critical. <br> a. True <br> b. False
g100num [7]

False

Not all IT services are equally critical. In an increasingly digital world whereby cyber threats are a big threat, it is vital to prioritize the critical assets in order to achieve digital resilience. This involves building tighter defenses in systems that are critical.

4 0
3 years ago
Software is the brain of computer. Explain this starement
Annette [7]

here you go

i hope this helps you

5 0
3 years ago
Difference between array processor and vector processor​
Gala2k [10]

Answer:

An array is used for the storaging the paticular given size element that is either fixed or given by the user. However an vector is also used for storing purpose but the size of the table is assign automatically during the running time of the program or we say dynamic size assign to table.

5 0
3 years ago
Read 2 more answers
Other questions:
  • Emma opened a new document a Microsoft word and typed her assignment. She is now planning to save the documents for the first ti
    11·1 answer
  • Write the C++ if statement that compares the contents of the quanity variable to the number 10. If the quantity variable contain
    12·1 answer
  • What is the maximum duration of daily Scrum meetings?
    13·1 answer
  • 1) List two hardware methods that can be used to secure data
    11·1 answer
  • What does the revolver do computer science​
    9·1 answer
  • Where does an antivirus run suspicious applications?
    12·1 answer
  • What is Error Code: 232011
    11·2 answers
  • Which two components are configured via software in order for a PC to participate in a network environment
    5·1 answer
  • How has the dependence on technology made humanity less intelligent?​
    15·1 answer
  • The aim of this activity is to implement an algorithm that returns the union of elements in a collection. Although working with
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!