The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 406 Weeks Ago, 1 Day Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Write a program that accepts input like the program in Display 7.8and that outputs a bar graph like the one in that display exceptthat your program will output the bars vertically rather thanhorizontally. A two-dimensional array may be useful.
Thats the question and here is what Display 7.8 looks like
#include <iostream>
#include <cmath>
const int NUMBER_OF_PLANTS = 4;
void input_data(int a[], int last_plant_number);
void scale(int a[], int size);
void graph(const int asterisk_count[], int last_plant_number);
void get_total(int& sum);
int round(double number);
void print_asterisks(int n);
int main()
{
using namespace std;
int production[NUMBER_OF_PLANTS];
cout << "This program displays agraph showing\n"
<< "production foreach plant in the company.\n";
input_data(production,NUMBER_OF_PLANTS);
scale(production, NUMBER_OF_PLANTS);
graph(production, NUMBER_OF_PLANTS);
return 0;
}
void input_data(int a[], int last_plant_number)
void get_total(int& sum)
void scale(int a[], int size)
int round(double number)
void graph(const int asterisk_count[], int last_plant_number)
{
using namespace std;
cout << "\nUnits produced inthousands of units:\n";
for (int plant_number = 1;
plant_number <= last_plant_number; plant_number++)
{
cout << "Plant #"<< plant_number << " ";
print_asterisks (asterisk_count[plant_number - 1]);
cout << endl;
}
}
void print_asterisks(int n)
{
using namespace std;
for (int count = 1; count <= n;count++)
cout << "*";
}
I guess the problem is, that I cant even get this to work. I have typed it in several times and was wondering if there is something obvious I am missing.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll