Sales Bar Chart Write a program that asks the user to enter today\'s sales for f
ID: 3604844 • Letter: S
Question
Sales Bar Chart 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 5Explanation / Answer
#include <iostream>
using namespace std;
int main() {
int sales[5];
for(int i=0;i<5;i++) {
cout<<"Enter today's sales for store "<<(i+1)<<": "<<endl;
cin >> sales[i];
}
cout<<"SALES BAR CHART"<<endl;
for(int i=0;i<5;i++) {
for(int j=0;j<sales[i]/100;j++) {
cout<<"*";
}
cout<<endl;
}
return 0;
}
Output:
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.