Advertisement
mecies

GRADE CALCULATOR

Jun 17th, 2018
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. public static void exit()
  2. {
  3. Environment.Exit(0);
  4. }
  5.  
  6. static void Main(string[] args)
  7. {
  8. // main
  9.  
  10. assign_grade();
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. // main //
  19. }
  20. static string assign_grade()
  21. {
  22. string[] grades = new string[6] { "A", "B+", "B", "C+", "C", "D" };
  23.  
  24. int max_score;
  25. int your_score;
  26. Console.WriteLine("enter the max score of your test");
  27. max_score = Convert.ToInt32(Console.ReadLine());
  28.  
  29. Console.WriteLine();
  30.  
  31. Console.WriteLine("enter your score");
  32. your_score = Convert.ToInt32(Console.ReadLine());
  33.  
  34. if (your_score > max_score)
  35. {
  36. Console.WriteLine("Why are you lying, press any key to exit the program");
  37. Console.ReadKey();
  38. exit();
  39. }
  40.  
  41. if (your_score >= max_score * 0.9)
  42. {
  43. Console.WriteLine("Your grade is: " + grades[0]);
  44. Console.ReadKey();
  45. return grades[0];
  46. }
  47. if (your_score < max_score * 0.9 && your_score >= max_score * 0.8)
  48. {
  49. Console.WriteLine("Your grade is: " + grades[1]);
  50. Console.ReadKey();
  51. return grades[1];
  52. }
  53. if (your_score < max_score * 0.8 && your_score >= max_score * 0.7)
  54. {
  55. Console.WriteLine("Your grade is: " + grades[2]);
  56. Console.ReadKey();
  57. return grades[2];
  58. }
  59. if (your_score < max_score * 0.7 && your_score >= max_score * 0.6)
  60. {
  61. Console.WriteLine("Your grade is: " + grades[3]);
  62. Console.ReadKey();
  63. return grades[3];
  64. }
  65. if (your_score < max_score * 0.6 && your_score >= max_score * 0.5)
  66. {
  67. Console.WriteLine("Your grade is: " + grades[4]);
  68. Console.ReadKey();
  69. return grades[4];
  70. }
  71. if (your_score <= max_score * 0.5)
  72. {
  73. Console.WriteLine("Your grade is: " + grades[5]);
  74. Console.ReadKey();
  75. return grades[5];
  76. }
  77. else
  78. {
  79. Console.WriteLine("Wrong input");
  80. return null;
  81. }
  82.  
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement