Oh, I did not see that one. Cpp, again, is definitely not my primary language; in fact, I only know a few phrases in it. All Joseph did here was replace the switch with a set of conditional statements. Functionally, they do the same thing, but, of course, they are syntactically different. If you know switches, I assume you already know conditionals (if else) statements. A third, more advanced way would be to store the possible responses in an array, then just try something like cout << responses[code] << endl; That would also require the cpp version of a try/catch (a way to catch an error, so you could make sure that you are not requesting a code outside of the array bounds). This is all unimportant, just something to ponder, and recognize later as you continue learning programming. On 7/10/10, Joseph Lee <joseph.lee22590@xxxxxxxxx> wrote: > Hi, > > I see. You are already learning switch statement? That's an impressive > progress. > > A brief hint: On the following lines, check out the display (cout) code. Do > you notice any difference: > > // Jess's version: > > cout << "Freshman."; << endl; > > // Joseph's version: > > cout << "Freshman." << endl; > > Notice that there is no semicolon after the text message. If you do put > semicolon, you'll get the syntax error because the compiler couldn't find > the output (cout) operator. A slightly better variation might be: > > cout << "Freshman".; > > cout << endl; > > Another hint (mostly an advice): In the conditional statement, you might > want to try "if" statement versus the "switch" statement. Here's how I would > do it (if I were you): > > // Joseph's variation: > > // Uses if statement to select a printout message. > > if (code == 1) > > cout << "Freshman." << endl; > > else if (code == 2) > > cout << "Sophomore." << endl; > > else if (code == 3) > > cout << "Junior." << endl; > > else if (code == 4) > > cout << "Senior." << endl; > > else > > cout << "Error: invalid code!" << endl; > > I (or someone) will explain the previous code in a sec. > > Cheers, > > Joseph > > > > > > > > From: programmingblind-bounce@xxxxxxxxxxxxx > [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jes > Sent: Saturday, July 10, 2010 7:21 PM > To: programmingblind@xxxxxxxxxxxxx > Subject: Syntax errors will be the death of me! > > > > Hey guys, > > Here's a code for an assignment which has to be turned in tomorrow. Every > time I try to compile it, Visual Studio keeps telling me I'm missing a ; > before << > > What's wrong? > > Code follows: > > //Ch6ConE06.cpp > > //Displays a class rank based on a code > > //entered by the user > > //Created/revised by <your name> on <current date> > > > > #include <iostream> > > > > using std::cout; > > using std::cin; > > using std::endl; > > > > int main() > > { > > //declare variable > > int code = 0; > > > > //enter input > > cout << "Enter the code: "; > > cin >> code; > > //enter switch statements > > switch(code) > > { > > case 1:; > > cout << "Freshman. " ; << endl; > > break; > > case 2: > > cout <<"Sophomore"; << endl; > > break; > > case 3: > > cout << "Junior "; << endl; > > break; > > case 4: > > cout << "Senior" ; << endl; > > break; > > case 5: > > cout << "Error! "; << endl; > > } > > //endswitch > > //display output > > > > return 0; > > } //end of main function > > > > Jes > > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 8.5.441 / Virus Database: 271.1.1/2992 - Release Date: 07/10/10 > 19:59:00 > > -- Have a great day, Alex (msg sent from GMail website) mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind