I'm doing my homework assignment for beginning C++ Class. I need to 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.
Example:
Enter today's sales for store 1: 1000
Enter today's sales for store 2: 1200
Enter today's sales for store 3: 1800
Enter today's sales for store 4: 800
Enter today's sales for store 5: 1900
SALES BAR CHART
(Each * = $100)
Store 1: *********
Store 2: ************
Store 3: *****************
Store 4: ********
Store 5: ******************
So I'm getting it a little. We have to use loops, no arrays. I have the following as my code. I'm able to input store data and it does display a sales bar chart but like this :
SALES BAR CHART
(Each * = $100)
Store 1:
Store 2:
Store 3:
Store 4:
Store 5:
******
Any help/advice would be greatly appreciated! I'm new the forums as well. I'm so thankful to have found this. I'm a nurse with NO programming experience, this is a whole new world to me!
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 28 29 30 31 32 33 34 35
|
#include <iostream>
using namespace std;
int main()
{
int store;
int profit;
char stars ='*';
cout <<"Enter today's sales for five different stores." <<endl;
for (int count=1; count<=5; count++)
{
cout<<"\n Enter today's sales for store "<<count<<":";
cin>> profit;
}
{
cout<<"SALES BAR CHART"<<endl;
cout<<"Each * = $100"<<endl;
for(int count = 1; count<= 5; count++)
cout << "Store " << count << ": "<<endl;
for (int stars = 0; stars < profit/ 100; stars++)
cout << "*";
cout << endl;
system ("pause");
}
return 0;
}
|