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
In Java :
Natali5045456 [20]

Answer:

The code to this question can be given as:

Code:

//define code.

//conditional statements.

   if (Character.isLetter(passCode.charAt(0))) //if block

   {

       System.out.println("Alphabetic at 0"); //print message.

   }

   if (Character.isLetter(passCode.charAt(1))) //if block

   {

       System.out.println("Alphabetic at 1"); //print message.

   }

Explanation:

In this code, we define conditional statement and we use two if blocks. In both if blocks we use isLetter() function and charAt() function. The isLetter() function checks the inserted value is letter or not inside this function we use charAt() function that checks inserted value index 1 and 2 is the character or not.

  • In first if block we pass the user input value and check the condition that if the inserted value is a character and its index is 0 so, it will print Alphabetic at 0.
  • In second if block we pass the user input value and check the condition that if the inserted value is a character and its index is 1 so, it will print Alphabetic at 1.
5 0
3 years ago
A ____________ is a collection of infected IT devices that an attacker or attack group controls.
sattari [20]
The answer would be a Botnet .
8 0
3 years ago
Which option is NOT in the Link to portion of the Insert Hyperlink dialog box?
WARRIOR [948]
Existing file or webpage
4 0
4 years ago
Read 2 more answers
Create a float variable named diameter. This variable will hold the diameter of a circle. d. Create a float variable named PI.
Basile [38]

Answer:

float diameter=2*r; //hold the diameter of a circle

float PI; // float variable named PI.

Explanation:

Here we have declared two variable i.e diameter and PI of type float. The variable diameter will hold the diameter of a circle i.e  2*r  where r is the radius of a circle.

Following are the program in c++

#include <iostream> // header file

using namespace std; // namespace

int main() // main function

{

   float r=9.2; // variable declaration

float diameter=2*r; //hold the diameter of a circle

float PI=3.14; // float variable named PI hold 3.14

cout<<"diameter IS :"<<diameter<<endl<<"PI IS :"<<PI; // display value

  return 0;

}

Output:

diameter IS :18.4

PI IS :3.14

8 0
3 years ago
Which details apply to a financing contract? Check all that apply
Nina [5.8K]
Correct answer choices are:

Requires a credit check
Includes interest rate information
Requires a signature for rent-to-own agreements

Contract finance is that the name was given to a debt that's provided after signing a legal contract document that your business has won and also the cash should be accustomed to complete the contract work.
3 0
3 years ago
Read 2 more answers
Other questions:
  • Which method of deleting files can be used in windows xp and vista?
    12·1 answer
  • The acronym LAH stands for
    14·2 answers
  • Create a class called Toddler that inherits from a class called Parent. (Note that Parent has already been defined elsewhere, so
    8·2 answers
  • Assume that a text box named PhoneNumberTextBox appears on a form and contains the phone number 414-555-5555. What value will di
    5·1 answer
  • Select the different network functions from the list below.
    10·1 answer
  • Which is the best reason for why it is important to be careful about entering personal information online?
    10·2 answers
  • Where do file name extensions appear?
    14·1 answer
  • What is the final step when creating an appointment to ensure that the content of the appointment is stored in Outlook?
    13·1 answer
  • True or false: If you have a 32-bit CPU architecture, it's recommended to use a 64-bit operating system.
    14·1 answer
  • What enforces the location in which an app can function by tracking the location of the mobile device?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!