fork download
  1. #include <iostream>
  2. #include <limits>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. cout << "Digite uma letra (A-F): " << endl;
  9.  
  10.  
  11. char grade;
  12.  
  13. while ((grade = cin.get()) != EOF)
  14. {
  15. cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
  16. switch ( grade )
  17. {
  18. case 'A':
  19. case 'a':
  20. cout << "A" << endl;
  21. break;
  22. case 'B':
  23. case 'b':
  24. cout << "B" << endl;
  25. break;
  26. case 'C':
  27. case 'c':
  28. cout << "C" << endl;
  29. break;
  30. case 'D':
  31. case 'd':
  32. cout << "D" << endl;
  33. break;
  34. case 'F':
  35. case 'f':
  36. cout << "F" << endl;
  37. break;
  38. default:
  39. cout << "Incorrect letter grade entered." << " Enter a new grade." << endl;
  40. break;
  41. }
  42.  
  43. }
  44. }
Success #stdin #stdout 0s 3472KB
stdin
B
c
x
stdout
Digite uma letra (A-F): 
B
C
Incorrect letter grade entered. Enter a new grade.