Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that lets the user enter four quarterly sales figures for three

ID: 3633592 • Letter: W

Question

Write a program that lets the user enter four quarterly sales figures for three divisions of a company. The figures should be stored in a two-dimensional array. Once the figures are entered, the program should display the following data for each quarter:
• A list of the sales figures by division
• The total sales for the quarter
• The average sales for all divisions that quarter
• The division with the highest sales for that quarter
The program should be modular, with functions that calculate the statistics above. Use the following sales table to test the program
Input Validation: Do not accept negative numbers for sales figures.


SALES:
Quarter 1 Quarter 2 Quarter 3 Quarter 4
Division 1 34 42 22 43
Division 2 33 33 40 28
Division 3 29 27 30 35

Explanation / Answer

please rate- thanks

#include <iostream>
#include <iomanip>
using namespace std;
void getData(double [][4]);
void salesByDiv(double [][4]);
void totalSalesQ(double [][4]);
void averageDiv(double [][4]);
void highestDiv(double [][4]);
double getTotal(double [][4],int);
int main()
{double sales[3][4];
cout<<setprecision(2)<<fixed<<showpoint;        
getData(sales);
salesByDiv(sales);
totalSalesQ(sales);
averageDiv(sales);
highestDiv(sales);
system("pause");
return 0;
}
void getData(double s[][4])
{int i,j;
cout<<"for each division enter sales data ";
for(i=0;i<3;i++)
   {cout<<"For Division "<<i+1<<endl;
    for(j=0;j<4;j++)
      {cout<<"for quarter "<<j+1<<": ";
       cin>>s[i][j];
       while(s[i][j]<0)
         {cout<<"invalid data-must be >=0 ";
          cout<<"for quarter "<<j+1<<": ";
          cin>>s[i][j];
         }
      }
   }
cout<<endl<<endl;
}
void salesByDiv(double s[][4])
{int i,j;
cout<<"Sales by Division ";
for(i=1;i<5;i++)
    cout<<"Quarter "<<i<<" ";
cout<<endl;
for(i=0;i<3;i++)
   {cout<<"Division "<<i+1<<" ";
      for(j=0;j<4;j++)
          cout<<s[i][j]<<" ";
    cout<<endl;
   }
}
double getTotal(double s[][4],int i)
{double total;
int j;
total = 0;
    for(j=0;j<3;j++)
       total+=s[j][i];
return total;
}
void totalSalesQ(double s[][4])
{double total;
int i;
cout<<"Total sales for quarter ";
   for(i=0;i<4;i++)
      cout<<"Quarter " <<i+1<<": $"<<getTotal(s,i)<<endl;
cout<<endl;
}
void averageDiv(double s[][4])
{int i;
double total,average;
cout<<"average sales for quarter ";
   for(i=0;i<4;i++)
      cout<<"Quarter " <<i+1<<": $"<<getTotal(s,i)/3.<<endl;
cout<<endl;
}

void highestDiv(double s[][4])
{int highest,i,j;
int qtr, div;
cout<<"division with the highest sales for the quarter ";
   for(i=0;i<4;i++)
   {highest=0;
    cout<<"Quarter "<<i+1;
    for(j=0;j<3;j++)
         if(s[j][j]>s[highest][i])
            highest=j;
     cout<<" - Division "<<highest+1<<" $"<<s[highest][i]<<endl;
     }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote