Question: (Sales Summary)}Use a two-dimensional array to solve the following problem. A company has four salespeople (1 to 4) who sell five different products (1 to

(Sales Summary)}Use a two-dimensional array to solve the following problem. A company has four salespeople (1 to 4) who sell five different products (1 to 5). Each salesperson passes in a slip for each different type of product sold. Each slip contains the following:}

a) The salesperson number b) The product number c) The total dollar value of that product sold that day

Thus, each salesperson passes in between 0 and 5 sales slips per day. Assume that the information from all of the slips for last month is available. Write a program that will read all this information for last months sales and summarize the total sales by salesperson by product. All totals should be stored in the two-dimensional array sales. After processing all the information for last month, print the results in tabular format with each of the columns representing a particular salesperson and each of the rows representing a particular product. Cross total each row to get the total sales of each product for last month; cross total each column to get the total sales by salesperson for last month. Your tabular printout should include these cross totals to the right of the totaled rows and to the bottom of the totaled columns.

I have solved most of the code but I can't figure out how to get the total for ALL of the products in the very last column/row.

my code:

#include

#include

using namespace std;

int main()

{

const int PEOPLE = 5, PRODUCTS = 6;

double sales[PEOPLE][PRODUCTS] = { 0.0 },

value, totalSales,productSales[PRODUCTS] = { 0.0 };

int salesPerson, product;

cout

cout

cin >> salesPerson;

while (salesPerson != -1)

{

cin >> product >> value;

sales[salesPerson][product] += value;

cin >> salesPerson;

}

cout

cout

// prints out the column for each product number (1-5) values

cout

for (int i = 1; i

{

totalSales = 0.0;

cout

for (int j = 1; j

{

totalSales += sales[i][j];

cout

productSales[j] += sales[i][j];

}

cout

}

cout

for (int j = 2; j

cout

cout

return 0;

}

my output: (Sales Summary)}Use a two-dimensional array to solve the following problem. A company

the output im trying to obtain: has four salespeople (1 to 4) who sell five different products (1

C:WINDOWS system32\cmd.exe Enter the salesperson (i - 4), product number (1 5 and total sales Enter 1 for the salesperson to end input. 1120 2215 333. 142.5 2510 1 The total sales for each salesperson are displayed at the end of each row, and the total sales for each product are displayed at the bottom of each 1 2 3 4 5 Total Total 20 . Press any key to continue -.-_

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!