You are requested by a SuperStore (Spar) in Soshanguve to calculate it’s earning for the week (the store opens the entire week) and determine the day with the highest and lowest earnings. The Store comprises of two sections namely the Food section and the Liquor store. Your C++ program should prompt the total sales for each section for each day and store the total sales for the day into an array. At the end of the week It should display a report for Management for the total sales for that week, the day the lowest sales and the day with the highest sales were recorded.
#include <iostream>
using namespace std;
void displayReport(float totalSales[]);
int main() {
float foodSectionTotalSales[7];
float liquorSectionTotalSales[7];
for(int day=0;day<7;day++){
float totalSales=-1;
while(totalSales<0){
cout<<"Enter the total sales for the day "<<(day+1)<<" for the Food section: ";
cin>>totalSales;
}
foodSectionTotalSales[day]=totalSales;
totalSales=-1;
while(totalSales<0){
cout<<"Enter the total sales for the day "<<(day+1)<<" for the Liquor section: ";
cin>>totalSales;
}
liquorSectionTotalSales[day]=totalSales;
}
cout<<"\nFood Section:\n";
displayReport(foodSectionTotalSales);
cout<<"Liquor Section:\n";
displayReport(liquorSectionTotalSales);
int pause;
cin>>pause;
return 0;
}
void displayReport(float totalSales[]){
int lowestDay=0;
int highestDay=0;
float lowestSales=totalSales[0];
float highestSales=totalSales[0];
float total_Sales=0;
for(int day=0;day<7;day++){
total_Sales+=totalSales[day];
if(lowestSales>totalSales[day]){
lowestSales=totalSales[day];
lowestDay=day;
}
if(highestSales<totalSales[day]){
highestSales=totalSales[day];
highestDay=day;
}
}
cout<<"The total sales for the week = "<<total_Sales<<"\n";
cout<<"The day the lowest sales = "<<(lowestDay+1)<<"\n";
cout<<"The day the highest sales = "<<(highestDay+1)<<"\n\n";
}
Comments
Leave a comment