Advertisement
KodingKid

C# Enum Grading System

May 1st, 2021
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. enum Grade { //makes the enum for grading
  2.     9 = A+, //grade level 9 = A+
  3.     8 = A, //and so on...
  4.     7 = B+,
  5.     6 = B,
  6.     5 = C+,
  7.     4 = C,
  8.     3 = D,
  9.     2 = E,
  10.     1 = F,
  11.     0 = U
  12.     }
  13. static void Main(string[] args)
  14. {
  15.     Grade myGrade = 5; //standard grade is a 5/C+
  16.     switch(myGrade) //changes the grade
  17.     {
  18.         case Grade.9: //if you get a 9...
  19.             Console.WriteLine("You got an A+") //you get an a+
  20.             break; //and that's it
  21.         case Grade.8: //and so on...
  22.             Console.WriteLine("You got an A")
  23.             break;
  24.         case Grade.7:
  25.             Console.WriteLine("You got a B+")
  26.             break;
  27.         case Grade.6:
  28.             Console.WriteLine("You got a B")
  29.             break;
  30.         case Grade.5:
  31.             Console.WriteLine("You got a C+")
  32.             break;
  33.         case Grade.4:
  34.             Console.WriteLine("You got a C")
  35.             break;
  36.         case Grade.3:
  37.             Console.WriteLine("You got a D")
  38.             break;
  39.         case Grade.2:
  40.             Console.WriteLine("You got an E")
  41.             break;
  42.         case Grade.1:
  43.             Console.WriteLine("You got an F")
  44.             break;
  45.         case Grade.0:
  46.             Console.WriteLine("You got an U")
  47.             break;
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement