#include
using namespace std;
int main()
{
int sales;
int store;
int asterisks;
int counter;
for (store = 1 ; store <= 5 ; store++)
{
cout << "Enter today's sales for store " << store << ": ";
cin >> sales;
}
cout << endl;
cout << "SALES BAR CHART" << endl;
cout << "(Each * = $100)" << endl;
for (store = 1 ; store <= 5 ; store++)
{
cout << "Store " << store << ": ";
asterisks = sales / 100;
for (counter = 1 ; counter <= asterisks ; counter++)
{
cout << '*';
}
cout << endl;
}
cout << endl;
system ("pause");
return 0;
}
-the program should be, when you type 300, the asterisks will out for 3 times.
-hint: don't use array
2007-03-17
04:03:56
·
6 answers
·
asked by
Nishimura Aina
1
in
Computers & Internet
➔ Programming & Design
the question:
Write a program that asks 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: *******************
2007-03-17
04:18:03 ·
update #1
i can't use array of pointers because this question is located under section looping.
so i have to use looping only.
i don't learn array and pointers yet.
2007-03-17
04:19:27 ·
update #2