I am getting an error message from line 62 stating: error C2143: syntax error : missing ';' before '+=' and I dont' know how to fix it.
Here is the code
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
#include <conio.h>
#include <iomanip>
using std::fixed;
using std::setw;
using std::setprecision;
using std::showpoint;
int main()
{
const static int PEOPLE = 5; //number of sales people (4)
const static int PRODUCTS = 6; //number of different products (5)
int sales[5][6] = {{1, 2, 3, 4}, {1, 2, 3, 4, 5}};
double value;
double totalSales;
double productSales[PRODUCTS] = {0.0};
int salesPerson;
int product;
cout << " Enter the salesperson's number (1-4), the product number (1-5), and total product sales.\n "
<< "Enter -1 for salesperson to end input.\n";
cin >> salesPerson;
while (salesPerson != -1)
{
cin >> product >> value;
value++;
cin >> salesPerson;
}
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;
}
cout << setw (12) << setprecision (2) << totalSales << '\n';
}
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;
_getch();
}
Any help would be appreciated!
chaoticabyss99, on 24 Jun, 2008 - 11:41 PM, said:
I am getting an error message from line 62 stating: error C2143: syntax error : missing ';' before '+=' and I dont' know how to fix it.
Here is the code
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
#include <conio.h>
#include <iomanip>
using std::fixed;
using std::setw;
using std::setprecision;
using std::showpoint;
int main()
{
const static int PEOPLE = 5; //number of sales people (4)
const static int PRODUCTS = 6; //number of different products (5)
int sales[5][6] = {{1, 2, 3, 4}, {1, 2, 3, 4, 5}};
double value;
double totalSales;
double productSales[PRODUCTS] = {0.0};
int salesPerson;
int product;
cout << " Enter the salesperson's number (1-4), the product number (1-5), and total product sales.\n "
<< "Enter -1 for salesperson to end input.\n";
cin >> salesPerson;
while (salesPerson != -1)
{
cin >> product >> value;
value++;
cin >> salesPerson;
}
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;
}
cout << setw (12) << setprecision (2) << totalSales << '\n';
}
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;
_getch();
}
Any help would be appreciated!
Line 62 is the += productSales;

New Topic/Question
Reply




MultiQuote



|