#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.
Enter -1 for the salesperson to end input.
";
cin >> salesPerson;
while ( salesPerson != -1 )
{
cin >> product >> value;
value++;
cin >> salesPerson;
} // end while
cout << "
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 column.
" << setw( 12 )
<< 1 << setw( 12 ) << 2 << setw( 12 ) << 3 << setw( 12 ) << 4
<< setw( 12 ) << 5 << setw( 13 ) << "Total
" << 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 << '
';
} // end for
cout << "
Total" << 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