// Timothy Price CS1A Ch5 Challenge 17
/*******************************************************************************
* Create chart
*
* This program receives values for a number of stores and creates a
* displayable bar graph with the received values.
*
* Inputs:
* Daily sales for each store
*
* Output:
* Bar graph
******************************************************************************/
#include <iostream>
#include <cmath>
using namespace std;
int main() {
// Data dictionary:
const int storenumber = 5;
int sales[storenumber]; // [ ] arrays used to avoid congestion
// Receive the sales for each store:
for (int base = 0; base < storenumber; base++) {
cout << "Enter today's sales for store " << (base + 1) << ": ";
cin >> sales[base];
cout << "$" << sales[base] << endl;
}
// Chart header:
cout << "__________________________________" << endl;
cout << "SALES BAR CHART" << endl << "(Each * = $100)" << endl;
// Create the bar graph for each store:
for (int base1 = 0; base1 < storenumber; base1++) {
cout << "Store " << (base1 + 1) << ": ";
// Round numbers down to the nearest $100 interval:
int numasterisks = sales[base1] / 100;
for (int base2 = 0; base2 < numasterisks; base2++) {
cout << "*";
}
cout << endl;
}
return 0;
}