hi, im tryin to get a swtich statement equivalent for the following:
1 2 3 4 5 6 7 8 9 10 11 12 13
if (letGrad == 'A')
cout << "The numerical grade is between 90 and 100";
elseif (letGrad == 'B')
cout << "The numerical grade is between 80 and 89.9";
elseif (letGrad == 'C')
cout << "The numerical grade is between 70 and 79.9";
elseif (letGrad == 'D')
cout << "How are you going to explain this one?";
else
{
cout << "Of course I had nothing to do with the grade.";
cout << "\nThe professor was really off the wall.";
}
The errors i am getting are:
error: case label `'A'' not within a switch statement
error: expected `;' before "break"
I'm a bit unsure of where to put objects n such. Here is my attempt:
#include <iostream>
usingnamespace std;
int main ()
{
char letGrad;
cin >> letGrad;
switch (letGrad);
{
case'A':
cout << "The numerical grade is between 90 and 100"break;
case'B':
cout << "The numerical grade is between 80 and 89.9" <<;
break;
case'C':
cout << "The numerical grade is between 70 and 79.9" <<;
break;
case'D':
cout << "How are you going to explain this one?" <<;
break;
}
cout << "Of course I had nothing to do with the grade.";
cout << "\nThe professor was really off the wall.";
system ("pause");
return 0;
}
Dear Jayray23
first of all line#12 has an extra semicolo.
line # 17 u did not end this line with semicolon so put it.
line# 21,25,29 has same problem.
You should write endl before semicolon or u should finsh(delete) the insertion operators from the end of these lines.