enum type with functions

ok so first im suppose to create an enumerated type called Grade. then
have two functions one function called void displayGrade(Grade)which I need to have as a switch statement which will display my grade,second function is Grade calculateGrade(int) which will receive 1 integer value and will return the correct grade based on the grading scheme in my syllabus but I don't quite understand how to do the enum this is what I have.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  enum Grade{A,B,C,D,F};
void displayGrade(Grade &grade);
int main()
{
 void displayGrade(Grade);
  return 0;
}


   void displayGrade(Grade grade)
{
  //cout<<"Your grade is"<<Grade<<endl;
  switch(grade)
    {
    case A :
      cout << "Excellent!" << endl;
      break;
    case B :
      cout<< "Well done" <<endl;
      break;
    case C :
      cout << "You passed" << endl;
      break;
    case D :
      cout << "Better try again" << endl;
      break;
    case F :
      cout << "You didn't pass" << endl;
      break;
    default :
      cout << "Invalid grade" << endl;
    }
   return;
}
Last edited on
You don't need single quote for using enum inside switch
Topic archived. No new replies allowed.