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
If I wanted to repeat an action such as a heading for a paper, it would be helpful to _____.
NemiM [27]
Possibly rephrase or rewrite the heading or whatever else you decide to repeat. You should never say the exact thing twice. 
Hope I helped :)
7 0
3 years ago
Read 2 more answers
What does module in Python do? How to install it? Thanks!
lyudmila [28]
A Python module is an extension file which contains programmable resources for a given translation unit. This is very much like a header file in C and C++, it's modularized data. For example, say I wanted to write a server/client script. I can't easily do so with Python out of the box. I would require the "socket" module which contains all of the functions, variables and data structures which allow for network programming.

network.py
___________
from socket import *

s = socket(AF_INET, SOCK_STREAM)
(...)
8 0
4 years ago
Which line of code will allow a decimal point to be stored in a variable?
Helga [31]

Answer:

a float value u mean right?Explanation:

8 0
3 years ago
Which attribute is used to specify the URL of a web page in a hyperlink?
seropon [69]

Answer:

href

Explanation:

HTML is an acronym for hypertext markup language and it is a standard programming language which is used for designing, developing and creating web pages.

Generally, all HTML documents are divided into two (2) main parts; body and head. The head contains information such as version of HTML, title of a page, metadata, link to custom favicons and CSS etc. The body of the HTML document contains the contents or informations that a web page displays.

A website refers to the collective name used to describe series of web pages linked together with the same domain name while a webpage is the individual HTML document (single page) that makes up a website with a unique uniform resource locator (URL).

In Web design, the attribute which is used to specify the uniform resource locator (URL) of a web page in a hyperlink is href.

Href is an abbreviation for hypertext reference and it's typically used with the anchor tag to link to another portion of the same web page or other web page of the same website.

For example, the syntax for href is;

<a href="https://www-brainly-com">My Assignment Page </a>

4 0
3 years ago
------------ is the process of communicating informationto lots of people at once e.g. via television, radio ornewspapersIntrape
balandron [24]

Answer:

Mass Communication

Explanation:

Mass Communication is the process of communicating information to lots of people at once.

6 0
3 years ago
Read 2 more answers
Other questions:
  • Convert each of the following for loops into an equivalent while loop. (You might need to rename some variables for the code to
    10·1 answer
  • ​PeroxyChem's IT staff was able to free its IT staff to spend less time on routine maintenance and more time on strategic tasks
    11·1 answer
  • --------------communication involves one speaker andaudience.
    12·1 answer
  • Why a design that doesn't fail initially fails after some time/use? identify at least 3 such mechanisms?
    9·1 answer
  • What type of control structure is the default method of the computer reading code?
    9·1 answer
  • Rob used Track Changes to suggest changes in Jack's document. Jack agrees with some edits and disagrees with others. What should
    14·1 answer
  • Help fast plzzzzzzzzzzzz ​
    10·2 answers
  • What might a designer need to consider when choosing an appropriate energy source for products and power systems
    15·1 answer
  • To add a hyperlink to your presentation, select the text, choose Hyperlink from the Insert menu, and then
    15·1 answer
  • What was the strategy the company adopted for ERP implementation?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!