fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int score;
  8. char grade;
  9. cout << "Enter your score:" << endl;
  10. cin >> score;
  11. if (score >= 90)
  12. grade = 'a';
  13. else if (score >= 80)
  14. grade = 'b';
  15. else if (score >= 70)
  16. grade = 'c';
  17. else if (score >= 60)
  18. grade = 'd';
  19. else
  20. grade = 'f';
  21.  
  22. cout << grade << endl;
  23. switch (grade)
  24. {
  25. case 'a':
  26. cout << "Good job" << endl;
  27. break;
  28. case 'c':
  29. cout << "Fair job" << endl;
  30. break;
  31. case 'f':
  32. cout << "Failure" << endl;
  33. break;
  34. default:
  35. cout << "invalid" << endl;
  36. }
  37. cin.get();
  38. return 0;
  39. }
  40.  
Success #stdin #stdout 0s 2728KB
stdin
95
stdout
Enter your score:
a
Good job