Sunday, August 2, 2009

I need help with C++! I AM GETTING THREES LIKE THESE: Error1error C2143: syntax error : missing ';' before '<<

I DON'T KNOW how to fix them!! help please!!


this is my code:


#include %26lt;iostream%26gt;


#include %26lt;string%26gt;


#include %26lt;iomanip%26gt;


#include %26lt;cctype%26gt;





using namespace std;





int main()


{


//declare variables


string itemNum = "";


int location = 0;





//get input from user


cout %26lt;%26lt; "Enter an item number: " %26lt;%26lt; endl;


cin %26gt;%26gt; itemNum;





//calculate shipping charge


while (itemNum != "x" %26amp;%26amp; itemNum != "X")


{


if (itemNum.length() != 5)


{


cout %26lt;%26lt; "The item number must contain five digits! " %26lt;%26lt; endl;


}


else if( 'B' == toupper(itemNum[2])) %26lt;%26lt;- Added ')';


{


cout %26lt;%26lt; "Your color is Blue" %26lt;%26lt;endl;


} %26lt;%26lt;- Added '}'


else if ('G' == toupper(itemNum[2])) %26lt;%26lt;- Added ')';


{


cout %26lt;%26lt; "the color is green" %26lt;%26lt; endl;


} %26lt;%26lt;- Added '}'


else


cout %26lt;%26lt; "Invalid item!" %26lt;%26lt;endl;


cout %26lt;%26lt; "Enter an item number: " %26lt;%26lt; endl;


cin %26gt;%26gt; itemNum;


} // Removed the extra }} and moved input within loop


return 0;


} //end of main function

I need help with C++! I AM GETTING THREES LIKE THESE: Error1error C2143: syntax error : missing ';' before '%26lt;%26lt;
You need to delete the semi-colon at the end of this line:





else if ('G' == toupper(itemNum[2])) %26lt;%26lt;- Added ')';
Reply:cout %26lt;%26lt; "Enter an item number: " %26lt;%26lt; endl;


becomes


cout %26lt;%26lt; "Enter an item number: ";


and so on


No comments:

Post a Comment