fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. //declare variables
  8. int membership;
  9. double purchase;
  10. double points;
  11.  
  12. //display menu
  13. cout << "Membership Types" << endl;
  14. cout << "1 Standard" << endl;
  15. cout << "2 Plus" << endl;
  16. cout << "3 Premium" << endl;
  17. cout << endl << "Select the membership type: ";
  18. cin >> membership;
  19.  
  20. if (membership < 1 && membership > 3)
  21. cout << "Invalid selection" << endl;
  22. else
  23. {
  24. cout << "Enter the total monthly purchase: ";
  25. cin >> purchase;
  26.  
  27. //calculate the reward points
  28. switch (membership)
  29. {
  30. case 1:
  31. if (purchase = 75.0)
  32. points = .05 * purchase;
  33. else if (purchase < 150.0)
  34. points = 7.5 * purchase;
  35. else
  36. points = .1 * purchase;
  37. //end if
  38.  
  39. case 2:
  40. if (purchase < 150.0)
  41. points = 0.6 * purchase;
  42. else
  43. points = .13 * purchase;
  44. //end if
  45. break;
  46. case 3:
  47. if (purchase < 200.0)
  48. points = .04 * purchase;
  49. else
  50. points = 15.0 * purchase;
  51. //end if
  52. } //end switch
  53.  
  54. //display reward points
  55. cout << fixed << setprecision(0);
  56. cout << "Reward points: " << purchase << endl;
  57. } //end if
  58.  
  59. // cin.ignore();
  60. // cin.get();
  61. return 0;
  62. } //end of main function
Success #stdin #stdout 0s 16048KB
stdin
Standard input is empty
stdout
Membership Types
1 Standard
2 Plus
3 Premium

Select the membership type: Enter the total monthly purchase: Reward points: 0