I am working on writing a code in C++ to use a switch statement to output a letter grade for class scores. The scores and corresponding letter grades are as follows:
90-100 = A
80-89 = B
70-79 = C
60-69=D
0-59 = F
Our teacher told us to use a control expression of (score/10). I have been trying to write this code and cant get it to work. Heres what I have. (excluding the usual things #include, return 0 etc)
CODE
int score;
cout<< "Enter your score as an integer and press enter: ";
cin >> score;
cout <<endl;
switch (score/10)
{
case '10':
case '9':
cout<< "Great! Your grade is an A.";
break;
}
The reason I used 10 and 9 is because score was declared as an integer so if your score is 97 and you divide that by 10 you are going to be given a integer. This code doesn't work. I didnt go through the whole thing because I wanted to make sure that it worked. If anyone could give me some help that would be great!!
** Edit **