#include #include const int NUMBER_OF_PLANTS = 4; void input_data(int a[], int last_plant_number); // Precondition: last_plnat_number is the declared size of the array a. // Postcondition: For plant_number = 1 through last_plant_number: //a[plant_number - 1] equals the total production of plant number plant_number. void scale(int a[], int size); //Precondition: a[0] through a[size - 1] each has a nonnegative value. //Postcondition: a[i] has been changede to the nubmer of 1000s (rounded to an integer) that were originally in a[i], for all i such that 0 <= i <= size - 1. void graph(const int asterisk_count[], int last_plant_nubmer); void get_total(int& sum); double round(double nubmer); void print_asterisks(int n); int main() { using namespace std; int production[NUMBER_OF_PLANTS]; cout << "This program displays a graph showing\n" << "production for each plant in the conpany. \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) { using namespace std; for (int plant_number = 1; plant_number <= last_plant_number; plant_number++) { cout << endl << "Enter prodcution data for plant nubmer " << plant_number << endl; get_total(a[plant_number - 1]); } } void get_total(int& sum) { using namespace std; cout << "Enter number of units produced by each department. \n" << "Appent a nueative nubmer to the end of the list.\n"; sum = 0; int next; cin >> next; while (next >= 0) { sum = sum + next; cin >> next; } cout << "Total = " << sum << endl; } void scale(int a[], int size) { for (int index = 0; index, size; index++) a[index] = round(a[index] / 1000.0); } double round(double number) { using namespace std; return static_cast(floor(number + 0.5)); } void graph(const int asterisk_count[], int last_plant_number) { using namespace std; cout << "\nUnits produced in thousands 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 << "*"; }