Here is the problem I'm suppose to figure out:
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 displaying a row of asterisks. Each asterisks should represent $100 of sales.
Her 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: *******************
Here is the code I got for this program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <iostream>
using namespace std;
int main()
{
int strs, y, x, sales;
strs = 100;
for (x = 1; x <= 5; x++)
cout << "Enter the sales for store\t\n" << x;
cin >> sales;
cout << "Sales Bar Chart\n";
strs = sales/100;
for (y = 1; y <= strs; y++)
strs = y/100;
cout << "*";
cout << endl;
return 0;
}
|
Here is the outcome I Get (We have to us nested For Loops):
Enter the sales for store
1Enter the sales for store
2Enter the sales for store
3Enter the sales for store
4Enter the sales for store
5
Sales Bar Chart
*
Press any key to continue ...
Basically I want to know, how do i make the "Enter the sales for store" thing look better and how do i get it where i can enter 5 numbers instead of just 1.
don't forget i have to use nested For Loops.
also how do i put the word store and its number before the asterisks.
cout << "Stores" << x << ":";
i got this but it says store 6 instead of store 1, i put it after
cout << "Sales Bar Chart\n";