Need Homework Help...I have code

I am trying to complete a C++ assignment for one of my classes and have become confused due to my inability to get it to compile. Everything seems to be in order, but no joy so far. Below I have posted my code along with the output of the compiler errors. Any assistance will be greatly appreciated.


#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 <strong class="highlight">PEOPLE</strong> = 5, <strong class="highlight">PRODUCTS</strong> = 6;
double <strong class="highlight">sales</strong>[ <strong class="highlight">PEOPLE</strong> ][ <strong class="highlight">PRODUCTS</strong> ] = { 0.0 }, value,
totalSales, productSales[ <strong class="highlight">PRODUCTS</strong> ] = { 0.0 };
int salesPerson, product;

cout << "Enter the <strong class="highlight">sales</strong> person <strong class="highlight"><vb_highlight>(1</strong></vb_highlight> - <strong class="highlight">4)</strong>, "
<< "product number <strong class="highlight"><vb_highlight>(1</strong></vb_highlight> - 5)\nand total <strong class="highlight">sales</strong>."
<< "Enter -1 for the <strong class="highlight">sales</strong> person <strong class="highlight"><vb_highlight>to</strong></vb_highlight> end input.\n";
cin >> salesPerson;

while ( salesPerson != -1 ) {
cin >> product >> value;
<strong class="highlight">sales</strong>[ salesPerson ][ product ] += value;
cin >> salesPerson;
}

cout << "\nThe total <strong class="highlight">sales</strong> for each <strong class="highlight">sales</strong> person "
<< "are displayed\nat the end <strong class="highlight">of</strong> each row,"
<< "and the total <strong class="highlight">sales</strong> for each\nproduct "
<< "are displayed at the bottom <strong class="highlight">of</strong> 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 < <strong class="highlight">PEOPLE</strong>; ++i ) {
totalSales = 0.0;
cout << i;

for ( int j = 1; j < <strong class="highlight">PRODUCTS</strong>; ++j ) {
totalSales += <strong class="highlight">sales</strong>[ i ][ j ];
cout << setw( 10 ) << setprecision( 2 )
<< <strong class="highlight">sales</strong>[ i ][ j ];
productSales[ j ] += <strong class="highlight">sales</strong>[ i ][ j ];
}

cout << setw( 10 ) << setprecision( 2 )
<< totalSales << '\n';
}

cout << "\nTotal" << setw( 6 ) << setprecision( 2 )
<< productSales[ 1 ];

for ( int j = 2; j < <strong class="highlight">PRODUCTS</strong>; ++j )
cout << setw( 10 ) << setprecision( 2 )
<< productSales[ j ];

cout << endl;
return 0;
}




Compiler Errors:
================
Compiler: Default compiler
Executing g++.exe...
Line Error
In function `int main()':
16: error: expected primary-expression before "const"
16: error: expected `;' before "const"
17: error: `double' is not a template
17: error: `strong' undeclared (first use this function)
17: error: (Each undeclared identifier is reported only once for each function it appears in.)
17: error: missing `>' to terminate the template argument list
17: error: expected primary-expression before "double"
17: error: expected `;' before "double"
17: error: expected primary-expression before ',' token
17: error: `value' undeclared (first use this function)
18: error: `totalSales' undeclared (first use this function)
18: error: `productSales' undeclared (first use this function)
18: error: expected primary-expression before '<' token
18: error: expected `]' before "class"
18: error: expected `;' before "class"
21: error: expected `;' before "highlight"
28: error: expected primary-expression before '<' token
28: error: expected `;' before "class"
32: error: expected `;' before "highlight"
41: error: expected primary-expression before '<' token
41: error: expected `;' before "class"
41: error: expected primary-expression before "class"
41: error: expected `)' before "class"
41: error: expected primary-expression before "class"
41: error: expected `;' before "class"
41: error: name lookup of `i' changed for new ISO `for' scoping
41: error: using obsolete binding at `i'
41: error: expected `;' before ')' token
59: error: expected primary-expression before '<' token
59: error: expected `;' before "class"
59: error: expected primary-expression before "class"
59: error: expected `)' before "class"
59: error: expected primary-expression before "class"
59: error: expected `;' before "class"
59: error: name lookup of `j' changed for new ISO `for' scoping
59: error: using obsolete binding at `j'
59: error: expected `;' before ')' token

Execution terminated
closed account (zb0S216C)
What's with all the XML/HTML tags? Are they supposed to be there? XML/HTML doesn't belong in C++ source code.

Wazzak
17: error: `double' is not a template

LOL. Never seen that one before.
That would be caused by...
double <strong class="highlight">
Which as Framework pointed out, HTML does not belong in C++ code...
Last edited on
I was just pointing out the hilariousness of said compilation error. I think we could all agree that the errors in this piece of code were obvious. The code must've been directly copied and pasted from a website. If so, this gives a whole new meaning to the term "copy and paste error".

Or it's a troll attempt:
http://www.daniweb.com/software-development/java/threads/212634

Also, you can tell by this which are the less creative profs...They get an F for plagiarism:
http://www.cerritos.edu/pnguyen/cis180fall05a7.htm
http://www.docstoc.com/docs/31400938/Computer-Programming-Lab-10
http://storm.cis.fordham.edu/~quist/csru1600/sales.cpp
Last edited on
Topic archived. No new replies allowed.