Answer to Question #220319 in C++ for MK MAELANE

Question #220319

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. Refer to below screen shot for sample Input and Output.


1
Expert's answer
2021-07-25T08:38:47-0400
#include<iostream>
using namespace std;
double getMin(double arr[], int n)
{
    
    return (n == 1) ? arr[0] : min(arr[0],
                         getMin(arr + 1, n - 1));
}
int main(){
    string week[7] = {"Sunday", "Monday", "Tuesday", "Wednesday","Thursday", "Friday","Saturday"};
    double sales [7]; 
    double food[7];
    double liqur[7];  
    for(int i =0; i<7; i++){
        cout<<"Enter the sales for food section day "<<(i + 1)<<endl;
        
        cin>>food[i];
        cout << "Sales for liquor section "<<i + 1 <<"\n";
        cin>>liqur[i];
        sales[i] = liqur[i]   + food [i] ;
    }
    double max = sales[0];
    for(int i=0; i<7; i++){
        if(sales[i] > max){
            max = sales[i];
        }
    }
    double total = 0;
    int indexH =0;
    int indexL = 0;
   for(int i =0; i<7; i++){
       total += sales[i];
       if(sales[i] == max){
           indexH = i;
       }
       else if(sales[i] == getMin(sales, 7)){
           indexL = i;
       }
       
   }
   cout<<"The total sales is \t"<<total<<endl;
    cout<<"The day with highest sales \t"<<week[indexH]<<"\nThe day with lowest sales\t"<< week[indexL];
    

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS