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
Power point 2016 which chart element provides the boundaries of the graphic?
SVEN [57.7K]
D. (chart elemments) - correct answer
8 0
3 years ago
The Sleeping-Barber Problem:
s2008m [1.1K]

Answer:

Explanation:

Following are the Semaphores:

Customers: Counts waiting customers;

Barbers: Number of idle barbers (0 or 1)

mutex: Used for mutual exclusion.

Cutting: Ensures that the barber won’t cut another customer’s hair before the previous customer leaves

Shared data variable:

count_cust: Counts waiting customers. ------------copy of customers. As value of semaphores can’t access directly.

// shared data

semaphore customers = 0; semaphore barbers = 0; semaphore cutting = 0; semaphore mutex = 1;

int count_cust= 0;

void barber() {

while(true) { //shop is always open

wait(customers); //sleep when there are no waiting customers

wait(mutex); //mutex for accessing customers1

count_cust= count_cust-1; //customer left

signal(barbers);

signal(mutex);

cut_hair();

}

}

void customer() {

wait(mutex); //mutex for accessing count_cust

if (count_cust< n) {

count_cust= count_cust+1; //new customer

signal(customers); signal(mutex);

wait(barbers); //wait for available barbers get_haircut();

}

else { //do nothing (leave) when all chairs are used. signal(mutex);

}

}

cut_hair(){ waiting(cutting);

}

get_haircut(){

get hair cut for some time; signal(cutting);

}

6 0
3 years ago
Core to resource management system is the _________that coordinates the server hardware.
vichka [17]
Hehdhdjdjddjdjid iridium chi jo j o j o j o j
5 0
2 years ago
If somebody is using a laptop at a coffee shop, how are they likely connected to a network?
marusya05 [52]

Answer:

by signing into the wifi network they have

Explanation:

4 0
3 years ago
What are the third generation of computer?​
balu736 [363]

The period of third generation was from 1965-1971. The computers of third generation used Integrated Circuits (ICs) in place of transistors. A single IC has many transistors, resistors, and capacitors along with the associated circuitry. The IC was invented by Jack Kilby.

3 0
3 years ago
Read 2 more answers
Other questions:
  • What is the on board storage C:
    15·1 answer
  • I've this assignment due before 7 am. Please help, me.
    9·1 answer
  • Complex communication skills will probably never be outsourced to a computer because they require the human touch.
    8·1 answer
  • The space force enhancement function concerned with providing data on meteorological, oceanographic, and space environmental fac
    12·1 answer
  • Write a program in c++ that asks the user for a sequence of n​integers, where the user provides the number of elements n​ then e
    12·1 answer
  • Psychographics may also be called A. personality analytics. B. social group dynamics. C. lifestyle analysis. D. opinion insight.
    6·1 answer
  • Anybody know this question??
    8·1 answer
  • The simplest element that exists is only one proton and one electron. It is what stars are made of. It's symbol is "H". What is
    9·1 answer
  • Please, ignore
    6·2 answers
  • Keeping memos on your checks is important because they
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!