I'm completely new to using case statements in C++ so bear with me. I'm trying to do a very simple case statement that will display the user to the user what grade they have got.
I know it is the "grade >=" ect parts that are wrong but I dont know how to right it so that it works. Anyone help?Code:#include <iostream> using namespace std; int main() { int grade; cout << "Please enter your grade"; cin >> grade; switch (grade) { case grade >= 70: cout << endl << "You got a grade A"; break; case grade >= 60: cout << endl << "You got a grade B1"; break; case grade >= 50: cout << endl << "You got a grade B2"; break; case grade >= 40: cout << endl << "You got a grade C"; break; case grade >= 30: cout << endl << "You got a grade D"; break; case grade == 30: cout << endl << "You Failed"; } return 0; }
Thanks.