Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 20th, 2012  |  syntax: C++  |  size: 0.84 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //Write a program that allows the user to enter the grade scored in a programming class (0-100).
  2. //If the user scored a 100 then notify the user that they got a perfect score.
  3.  
  4. //★ Modify the program so that if the user scored a 90-100 it informs the user that they scored an A
  5.  
  6. //★★ Modify the program so that it will notify the user of their letter grade
  7.  
  8. //0-59 F 60-69 D 70-79 C 80-89 B 90-100 A
  9.  
  10. #include <iostream>
  11.  
  12. using namespace std;
  13.  
  14. int main(){
  15.  
  16. int x;
  17.  
  18. cout << "Enter your grade: \n";
  19. cin >> x;
  20. switch(x)
  21. {
  22. case x<=59: cout << "F\n";
  23. break;
  24. case 59<x<=69: cout << "D\n";
  25. break;
  26. case 69<x<=79: cout << "C\n";
  27. break;
  28. case 79<x<=89: cout << "B\n";
  29. break;
  30. case 89<x<=99: cout << "A\n";
  31. break;
  32. case x==100: cout << "A, Perfect Score!\n";
  33. break;
  34. default: cout << "Please enter a valid grade";
  35. break;
  36. }
  37. cin.get();
  38. }