Write a program that allows the user to enter the grade scored in a programming class (0-100).
If the user scored a 100 then notify the user that they got a perfect score.
★ Modify the program so that if the user scored a 90-100 it informs the user that they scored an A
★★ Modify the program so that it will notify the user of their letter grade
0-59 F 60-69 D 70-79 C 80-89 B 90-100 A
Can someone tell me how can I enter a number and that number will tell which grade I have. For example I wanna type 55 and when I typed it I want that the program to tell me F. How can I do that ?
You won't be able to use a switch-statement anymore, because that only checks for equality. What you need to check is whether a number is in between a range of numbers, so if/else if statements will serve that purpose. Note that '&&' is the operator for logical AND, meaning both conditions need to be true:
1 2 3 4 5 6 7
if (x >= 0 && x < 60)
std::cout << " F ";
elseif (x >= 60 && x < 70)
std::cout << " D ";
//etc.