A number of things are going on here. Firstly, I don't know if you're writing a function that calculates the grade or if this is supposed to go in main, but either way you can't have just a switch statement and call it done.
Secondly, case is followed by a colon :, not a semicolon ;.
Thirdly, you forgot a break at the end before default.
The general syntax for a switch statement is:
1 2 3 4 5 6
switch(variable)
{
case 1: (code); break;
case 2: (code); break;
default: (code);
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
usingnamespace std;
int main()
{
char grade = 'A';
switch (grade)
{
case'A': cout << "The grade point is 4.0."; break;
case'B': cout << "The grade point is 3.0."; break;
case'C': cout << "The grade point is 2.0."; break;
case'D': cout << "The grade point is 1.0."; break;
case'F': cout << "The grade point is 0.0."; break;
default: cout << "The grade is invalid.";
}
}