Write a program that asks the user to enter today`s sales for five stores.

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 sales. Create each bar in the graph by displaying a row of asterisks. Each asterisk represents 100 of each sale. Here is the Example of the program output.

Enter today sale for store 1: 1000[Enter] 

Enter today sale for store 2: 1200[Enter] 

Enter today sale for store 3: 1800[Enter] 

Enter today sale for store 4: 800[Enter]

Enter today sale for store 5: 1900[Enter] 

Sales bar chart Store 1: ********** 

Store 2: ************ 

Store 3: ****************** 

Store 4: ******** 

Store 5: *******************

code :

#include <iostream>

using namespace std;

int main()

{

int sales = 0;

int store = 0;

int stars;

for (int store = 1; store <= 5; store++)

{

cout << "Enter today's sale for store " << store << ":";

cin >> sales;


cout << "SALES BAR CHART:" << endl;

cout << "(Each * = $100)" << endl;

stars = sales / 100;

cout << "Store" << store << ":";

for (int y = 0; y < stars; y++)

{

cout << "*";

}

cout << endl;

}

system("PAUSE");

return 0;

}

output:

Enter today's sale for store 1:1000

SALES BAR CHART:

(Each * = $100)

Store1:**********

Enter today's sale for store 2:1200

SALES BAR CHART:

(Each * = $100)

Store2:************

Enter today's sale for store 3:1800

SALES BAR CHART:

(Each * = $100)

Store3:******************

Enter today's sale for store 4:800

SALES BAR CHART:

(Each * = $100)

Store4:********

Enter today's sale for store 5:1900

SALES BAR CHART:

(Each * = $100)

Store5:*******************

Post a Comment

0 Comments