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

C++ Question Midterm Exam Program Instructions Use a two-dimensional array to so

ID: 643937 • Letter: C

Question

C++ Question

Midterm Exam Program Instructions Use a two-dimensional array to solve the following problem: A company has four sales people (1 thru 4) who sell 5 different products (1 thru 5). Once a day, each sales person turns in a form with his sales listed (see below). Each form contains the following information: 1. The salesperson number 2. The product numbers 3. The total dollar value for each product Each salesperson's form contains a total for 0 to 5 products per day. Assume that the information from all of the forms for last week is available. Write an application that will allow the user to enter all of this information for last week's sales. The program should summarize the totals sales by salesperson and by product until the user enters a -1. All totals should be stored in the two-dimensional array sales. After the user enters all of the information for the last week, display the results in a tabular format, with each column representing a salesperson and each row representing a particular product. Cross-total each row to get the total sales of each product for the last week. Cross-total each column to get the total sales by salesperson for the last week. Your output should include these cross-totals to the right of the totaled rows and at the bottom of the totaled columns. Use the system ''PAUSE'' command to pause the display so you can view it on the console. To test your program create your own data for days 2 thru 5.

Explanation / Answer

#include <iostream>
using namespace std;

int main() {
   // your code goes here
   int pid1[4],pid2[4],pid3[4],pid4[4];
   float cost[16];
   char name[16][10];
   int p=0;
   int ct=0;
   int n=0;
   int c=0;
   while(c!=-1){
   cout<<"Enter sales person ID product name and product cost"<<endl;
   if(p%4==0)
   cin>>pid1[p];
   else if(p%4==1)
   cin>>pid2[p];
       else if(p%4==2)
   cin>>pid3[p];
       else if(p%4==3)
   cin>>pid4[p];
  
   cin>>cost[ct];
   cin>>name[n][10];
   p++;ct++;n++;
   cout<<"Enter -1 to quit other number to continue"<<endl;
   cin>>c;
   }
   int i;
   float sum=0.0;
   cout<<"Sales PersonID prodA prodb prodc prodd total";
   cout<<pid1[i];
   for(i=0;i<4;i++)
   {
   cout<<" "<<cost[i];
   sum=sum+cost[i];
   }
       cout<<" "<<sum<<" ";
   cout<<pid2[i];
   for(i=4;i<8;i++)
   {
   cout<<" "<<cost[i];
   sum=sum+cost[i];
   }
   cout<<" "<<sum<<" ";
   cout<<pid3[i];
   for(i=8;i<12;i++)
   {
   cout<<" "<<cost[i];
   sum=sum+cost[i];
   }
   cout<<" "<<sum<<" ";
   cout<<pid4[i];
   for(i=12;i<16;i++)
   {
   cout<<" "<<cost[i];
   sum=sum+cost[i];
   }
   return 0;
}

//i assumed u give prod names as proda prodb.... and i've calculated row wise total similarly u can do column wise. it's too time taking so i dnt have time so....

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