fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. #include <cmath>
  5. using namespace std;
  6.  
  7. int main () {
  8.  
  9. int numberOfPackages;
  10. int totalPhoneUsage;
  11. int includedMinutes;
  12.  
  13. //change const to capital
  14.  
  15. // Fees, Minutes Provided, rate for additonal ,minutes
  16. const float monthlyFeeA = 39.99;
  17. const int minProvidedA = 450;
  18. const float rateForAddMinA = 0.45;
  19.  
  20. const float monthlyFeeB = 59.99;
  21. const int minProvidedB = 900;
  22. const float rateForAddMinB = 0.40;
  23.  
  24. const float monthlyFeeC = 69.99;
  25.  
  26. float totalSubPrice;
  27.  
  28. cout<< "Select a subcription package: \n"
  29. <<"1. Package A\n"
  30. <<"2. Package B\n"
  31. <<"3. Package C\n"
  32. <<"4. Quit\n";
  33.  
  34.  
  35.  
  36.  
  37. // User inputs which packaged theyed like
  38.  
  39. cin >> numberOfPackages;
  40. switch (numberOfPackages){
  41.  
  42. case 1:{
  43.  
  44. cout << "You selected Package A\n";
  45.  
  46. break;
  47. }
  48.  
  49. case 2:{
  50.  
  51. cout << "You selected Package B\n";
  52. break;
  53. }
  54. case 3:{
  55.  
  56. cout << "You selected Package C\n";
  57. break;
  58. }
  59. case 4: {
  60.  
  61. cout << "You selected Quit\n";
  62. break;
  63. return 0;
  64. }
  65. default: {
  66. cout << "The valid choices are 1 through 4. Run program again and select one of those.\n";
  67. break;
  68. return 0;
  69. }
  70. }
  71.  
  72. //Asking user for input on total phone usage in minutes
  73.  
  74. cout << "How many minutes were used?: ";
  75. cin >> totalPhoneUsage;
  76.  
  77.  
  78. // if else branches to determine additional rate, included min and monthly fee
  79. // add set precision finish code, delete unneeded variables.
  80.  
  81.  
  82. if (numberOfPackages == 1){
  83. if (totalPhoneUsage <= minProvidedA){
  84. cout << "The total amount due is $ "<< monthlyFeeA;
  85. }
  86.  
  87. else if (totalPhoneUsage > minProvidedA) {
  88. float totalOver = (totalPhoneUsage - minProvidedA) * rateForAddMinA;
  89. float totalDue = monthlyFeeA + totalOver;
  90. cout << "The total amount due is:$ " << totalDue << endl;
  91. }
  92. }
  93.  
  94.  
  95.  
  96. else if (numberOfPackages == 2){
  97. if (totalPhoneUsage <= minProvidedB) {
  98. cout << "The total amount due is $ "<< monthlyFeeB; }
  99.  
  100. else if (totalPhoneUsage > minProvidedB){
  101. float totalOver = (totalPhoneUsage - minProvidedB) * rateForAddMinB;
  102. float totalDue = monthlyFeeB + totalOver;
  103. cout << "The total amount due is:$ " << totalDue << endl;
  104. }
  105. }
  106.  
  107.  
  108.  
  109. else if (numberOfPackages == 3) {
  110. cout << "The total amount due is $ " << monthlyFeeC << endl;
  111. }
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122. return 0;
  123. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Select a subcription package: 
1. Package A
2. Package B
3. Package C
4. Quit
The valid choices are 1 through 4. Run program again and select one of those.
How many minutes were used?: