I am trying to solve a problem from a lab challenge. I can not get the program to compile correctly. Please look over and let me know where I need to be looking to solve this

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). Once a day, 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 month’s 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

My coding:

#include <iostream> 
using std::cin; 
using std::cout; 
using std::endl; 
using std::ios;

#include <iomanip>
using std::fixed;
using std::setw; 
using std::setprecision; 
using std::showpoint;

int main()
{
   const int PEOPLE = 5;
   const int PRODUCTS = 6;
  
   int sales[5][6]={{1},{2},{3},{4}};
   double value;
   double totalSales;
   double productSales[ PRODUCTS ] = { 0.0 };
   int salesPerson;
   int product;
   
   
   cout << "Enter the salesperson (1 - 4), product number (1 - 5), and "
        << "total sales.\nEnter -1 for the salesperson to end input.\n";
   cin >> salesPerson;
   
   while ( salesPerson != -1 ) 
   {
      cin >> product >> value;
      
	  value++;
      cin >> salesPerson;
   } // end while

   cout << "\nThe total sales for each salesperson are displayed at the "
        << "end of each row,\n" << "and the total sales for each product "
        << "are displayed at the bottom of each column.\n " << setw( 12 ) 
        << 1 << setw( 12 ) << 2 << setw( 12 ) << 3 << setw( 12 ) << 4 
        << setw( 12 ) << 5 << setw( 13 ) << "Total\n" << fixed << showpoint;

   for ( int i = 1; i < 4; i++ ) 
   {
      totalSales = 0.0;
      cout << i;
      
      for ( int j = 1; j < 5; j++ ) 
      {
		  ++ totalSales;

         cout << setw( 12 ) << setprecision( 2 ) << sales[ i ][ j ];
         
		  += productSales ;
      } // end for

      cout << setw( 12 ) << setprecision( 2 ) << totalSales << '\n';
   } // end for
   
   cout << "\nTotal" << setw( 8 ) << setprecision( 2 ) 
      << productSales[ 1 ];

   // display total product sales
   for ( int j = 2; j < totalSales; j++ )
      cout << setw( 12 ) << setprecision( 2 ) << productSales[ j ];

   cout << endl;
   return 0; // successful termination
} // end main

two dimesional arrays have to displayed as 2 dimension like a[j], you can't write them as a single array a. I think this is why ur program is not compiling.

I think I got it! I worked and it looks like it is working great. Thanks for the reply!
M~

#include <iostream>

using std::cout;
using std::cin;
using std::endl;
using std::ios;

#include <iomanip>

using std::setiosflags;
using std::setprecision;
using std::setw;

int main()
{
   const int PEOPLE = 5, PRODUCTS = 6;
   double sales[ PEOPLE ][ PRODUCTS ] = { 0.0 }, value,
         totalSales, productSales[ PRODUCTS ] = { 0.0 };
   int salesPerson, product;
   
   cout << "Enter the sales person (1 - 4), "
        << "product number (1 - 5)\nand total sales."
        << "Enter -1 for the sales person to end input.\n";
   cin >> salesPerson;
   
   while ( salesPerson != -1 ) {
      cin >> product >> value;
      sales[ salesPerson ][ product ] += value;
      cin >> salesPerson;
   }

   cout << "\nThe total sales for each sales person "
        << "are displayed\nat the end of each row,"
        << "and the total sales for each\nproduct "
        << "are displayed at the bottom of each column.\n"
        << setw( 10 ) << 1 << setw( 10 ) << 2
        << setw( 10 ) << 3 << setw( 10 ) << 4
        << setw( 10 ) << 5 << setw( 12 ) << "Total\n"
        << setiosflags( ios::fixed | ios::showpoint );

   for ( int i = 1; i < PEOPLE; ++i ) {
      totalSales = 0.0;
      cout << i;
      
      for ( int j = 1; j < PRODUCTS; ++j ) {
         totalSales += sales[ i ][ j ];
         cout << setw( 10 ) << setprecision( 2 )
              << sales[ i ][ j ];
         productSales[ j ] += sales[ i ][ j ];
      }

      cout << setw( 10 ) << setprecision( 2 )
           << totalSales << '\n';
   }
   
   cout << "\nTotal" << setw( 6 ) << setprecision( 2 )
        << productSales[ 1 ];

   for ( int j = 2; j < PRODUCTS; ++j )
      cout << setw( 10 ) << setprecision( 2 )
           << productSales[ j ];

   cout << endl;
   return 0;
}
This question has already been answered. Start a new discussion instead.