-
Switch Statements
So in my computer science class my teacher refuses to help us.
Someone else please help me with this :/
Rerite the following nested if using a switch statement.
if (Score == 1)
cout << "Poor" << endl;
else if (Score == 2)
cout << "Fair" << endl;
else if (Score == 3)
cout << "Average" << end;
else if (Score ==4)
cout << "Good" << endl;
else
cout << "Excellent" << endl;
Please help!
-
-
http://www.cprogramming.com/tutorial/lesson5.html
I don't think it's a matter of your teacher refusing to help you but a matter of your teacher refusing to explain switch statements again because no one listened the first time around.
-
It's trivial if you read anu lesson about switch, but here's the code:
Code:
switch (Score)
{
case 1:
cout << "Poor" << endl;
break;
case 2:
cout << "Fair" << endl;
break;
case 3:
cout << "Average" << end;
break;
case 4:
cout << "Good" << endl;
break;
default:
cout << "Excellent" << endl;
}
-
Hey thanks guys. I'll definetly read more about it. When I read it in my book it's like I have to decode the book too cuz its so confusing lol.