CODE
// Your code
switch (choice)
{
case 'A':
case 'a':
cout << "How many apples?"
cin >> count;
total+=(count * apples);
break;
}
You're missing a semicolon after the cout line. Also, here is an example:
CODE
switch(variable)
{
case 1:
// do stuff
break;
case 2:
case 3:
// 2 and 3 do stuff here
break;
}
You're code has copies of
cases in brackets. You can surround it all in the single
switch statement since the variable inside is always what you want to compare inside the statement.
If you want to handle a case where none of the previous cases match, use the
default statement.
CODE
switch(variable)
{
case 1:
// do stuff
break;
case 2:
case 3:
// 2 and 3 do stuff here
break;
default:
// Not 1, 2, or 3 since none of them match, do stuff in here then
break;
}
This post has been edited by WolfCoder: 21 Feb, 2007 - 07:38 PM