Making a Bar Graph
So I have this code and the issue I'm having is at the end it is suppose to display stars that shows the sales for each of the five stores. It only prints the last value entered so the store amount for "Store 5" would print on all of them. Any suggestions? /*This program will ask the user to input the sales amount for 5 different stores and will display a bar graph based on their input*/ #include <iostream> #include <cmath> using namespace std; int main() { const int SALES = 100; const int STORES = 5; int count; int total; int bar; cout << "Welcome to the Sales Total Bar Charter!" << endl; for (count = 1; count <= STORES; count++) { cout << "Enter today's sales for store " << count << ": " << flush; cin >> total; while (total < 0) { cout << "Invalid: input MUST be positive." << endl; cout << "Enter today's sales for store " << count << ": " << flush; cin >> total; } } cout << "\nSALES BAR CHART" << endl; for (count = 1; count <= STORES; count++) { bar = total / SALES; cout << "Store " << count << ": " << flush; for (int i = 0; i < bar; i++) { cout << '*'; } cout << endl; } cout << "\nThanks for using the Bar Charter" << endl; return 0; }