fork download
  1. //@Author Damien Bell
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. int main(){
  6. int grade=0;
  7.  
  8. cout << "Enter the student's grade (1-100):";
  9. cin >> grade;
  10.  
  11. while (grade < 1 || grade > 100){
  12. cout << "\nEnter the student's grade, the number you entered was invalid: ";
  13. cin >> grade;
  14. }
  15.  
  16. grade /= 10; // 90 -> 9
  17.  
  18. if (grade <5){
  19. grade = 5;
  20. }
  21.  
  22. switch(grade){
  23. case 5:{
  24. cout <<"\nYou got an F, Needs improvement";
  25. break;
  26. }
  27. case 6:{
  28. cout <<"\nYou got an D, Needs improvement";
  29. break;
  30. }
  31. case 7:{
  32. cout <<"\nYou got an C, You're average";
  33. break;
  34. }
  35. case 8:{
  36. cout <<"\nYou got an B, Well done";
  37. break;
  38. }
  39. case 9:{
  40. cout <<"\nYou got an A, Very well done";
  41. break;
  42. }
  43. case 10:{
  44. cout <<"\nYou got an A+, Holy crap!!";
  45. break;
  46. }
  47. default:{
  48. cout << "\nSomething went wrong";
  49. }
  50.  
  51. }//End switch
  52.  
  53.  
  54.  
  55.  
  56. return 0;
  57. }
  58.  
  59.  
  60. //A - F
  61. //1 - 100
  62. //90-100 A
  63. //80-89 B
  64. //70-79 C
  65. //60-69 D
  66. // 0-59 F
Success #stdin #stdout 0s 2728KB
stdin
87
stdout
Enter the student's grade (1-100):
You got an B, Well done