I have some trouble here with the program, my specific problem is that I don't know how to display the asterisks at all. I don't know how to finish it.
Question: Write a program that asks the user to enter today’s sales for five stores. The program
should then display a bar graph comparing each store’s sales. Create each bar in the bar
graph by displaying a row of asterisks. Each asterisk should represent $100 of sales.
Here is an example of the program’s output.
Enter today's sales for store 1: 1000 [Enter]
Enter today's sales for store 2: 1200 [Enter]
Enter today's sales for store 3: 1800 [Enter]
Enter today's sales for store 4: 800 [Enter]
Enter today's sales for store 5: 1900 [Enter]
SALES BAR CHART
(Each * = $100)
Store 1: **********
Store 2: ************
Store 3: ******************
Store 4: ********
Store 5: *******************
My plan was:
- Make for loop asking today's sales for 5 stores.
- Get answer for variable "Store 1" and divide by 100 to get asterisks.
- For every 100, display asterisk.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <iostream>
using namespace std;
int main()
{
int store1;
int stars;
for (int i = 1; i <= 5; i++)
{
cout << "Enter today's sales for store: " << i << endl;
cin >> store1;
stars = (store1 / 100);
}
for (int b = 1; b <= 5; b++)
{
cout << "For Store: " << b << endl;
{
}
}
return 0;
}
|