//Mahmoud Saleh CSC5 *Forked* Chapter 5 #17, P297
//
/****************************************************************************************************
*
* Compare Store Sales
*__________________________________________________________________________________
* This program accepts sales data from a number of stores and displays those data
* in the form of a bar graph.
*
*__________________________________________________________________________________
* INPUT
* storeData : The revenue of each store
* Number of stores
* Plot symbol
*
* OUTPUT
* store1 : Amount made by store 1 represented by '*'
* store2 : Amount made by store 2 represented by '*'
* store3 : Amount made by store 3 represented by '*'
* store4 : Amount made by store 4 represented by '*'
* store5 : Amount made by store 5 represented by '*'
* bar graph comparing stores using '*'
* A traditional bar graph representing the sales of each store by store.
*
****************************************************************************************************/
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
//Declaring variables
int count; //Count for 'for loop'
int count2; //Count for while loop to concatanate '*'
int store; //Sales Revenue input by user
int starNum; //Number of stars (points) based on revenue
string storeStar; //Concatanated string of total number of stars
string store1; //Number of stars for store one
string store2; //Number of stars for store two
string store3; //Number of stars for store three
string store4; //Number of stars for store four
string store5; //Number of stars for store five
//Establishing for loop to run for 5 iterations
for(count = 0; count<5; count++)
{
//Initializing and resetting variables
store = 0;
count2 = 0;
starNum =0;
storeStar = "";
//Using while loop to validate input making sure its a positive integer
cout << "Enter today's sales for store " << count + 1 << ":\n";
cin >> store;
while(store<0) //conver this to standard input validation
{
cout << "Invalid Input store " << endl;
cout << "Enter today's sales for store " << count + 1 << ":\n";
cin >> store;
}
//Dividing input value by 100 and assigning it to starNum (number of points)
starNum = store/100;
//While loop to assign "*" points to the store based on input
while (count2 < starNum)
{
storeStar += "*";
count2 += 1;
}
//Switch statement to assign the total points to the exact store
switch(count+1)
{
case 1:
store1 = storeStar;
break;
case 2:
store2 = storeStar;
break;
case 3:
store3 = storeStar;
break;
case 4:
store4 = storeStar;
break;
case 5:
store5 = storeStar;
break;
}
}
//Displaying comparison bar graph
cout << endl;
cout << "SALES BAR CHART" << endl;
cout << "(Each * = $100)" << endl;
cout << "Store 1: " << store1 << endl;
cout << "Store 2: " << store2 << endl;
cout << "Store 3: " << store3 << endl;
cout << "Store 4: " << store4 << endl;
cout << "Store 5: " << store5 << endl;
return 0;
}