showing grades of student by using switch statement?

how to display grades of student and dislayas shown below in C++
grade Result
A+ Excelent
A Good
B Satisfactord
C Pass
Switch statements evaluate const expressions and as a range of results are likely to be deemed 'excellent', 'good' etc you can't use the result values outright. Pass the results through an enum first:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
enum Grade{Excellent, Good, Satisfactory, Pass, Fail};
//...
//
Grade tier{};
//...
else if (result >= 60 && result < 80)
    {
        tier = Satisfactory;//for example
    }
//...
 switch (tier){
//...
case (Satisfactory):
        std::cout << "Satisfactory \n";
        break;
//...
}
Topic archived. No new replies allowed.