fork(1) 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. //change const to capital
  13. const float monthlyFeeA = 39.99;
  14. const int minProvidedA = 450;
  15. const float rateForAddMinA = 0.45;
  16.  
  17. const float monthlyFeeB = 59.99;
  18. const int minProvidedB = 900;
  19. const float rateForAddMinB = 0.40;
  20.  
  21. const float monthlyFeeC = 69.99;
  22.  
  23. float totalSubPrice;
  24.  
  25. cout<< "Select a subcription package: \n"
  26. <<"1. Package A\n"
  27. <<"2. Package B\n"
  28. <<"3. Package C\n"
  29. <<"4. Quit\n";
  30.  
  31.  
  32.  
  33.  
  34. // User inputs which packaged theyed like
  35. cin >> numberOfPackages;
  36. switch (numberOfPackages){
  37.  
  38. case 1:{
  39.  
  40. cout << "You selected Package A\n";
  41.  
  42. break;
  43. }
  44.  
  45. case 2:{
  46.  
  47. cout << "You selected Package B\n";
  48. break;
  49. }
  50. case 3:{
  51.  
  52. cout << "You selected Package C\n";
  53. break;
  54. }
  55. case 4: {
  56.  
  57. cout << "You selected Quit\n";
  58. break;
  59. }
  60. default: {
  61. cout << "The valid choices are 1 through 4. Run program again and select one of those.\n";
  62.  
  63. break;
  64. }
  65. }
  66.  
  67. //Asking user for input on minutes
  68.  
  69. cout << "How many minutes were used?: ";
  70. cin >> totalPhoneUsage;
  71.  
  72. // if else branches to determin additional rate, included min and monthly fee
  73.  
  74. if (numberOfPackages == 1){
  75. if (totalPhoneUsage <= minProvidedA){
  76. cout << "The total amount due is $ \n"<< monthlyFeeA;
  77. }
  78. else if (totalPhoneUsage > minProvidedA){
  79. float totalOver = (totalPhoneUsage - minProvidedA) * rateForAddMinA;
  80. float totalDue = monthlyFeeA + totalOver;
  81. cout << "The total amount due is:$ " << totalDue << endl;
  82. }
  83.  
  84. // add set precision finish code, delete unneeded variables.
  85. }
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92. return 0;
  93. }
Success #stdin #stdout 0.01s 5320KB
stdin
1
500
stdout
Select a subcription package: 
1. Package A
2. Package B
3. Package C
4. Quit
You selected Package A
How many minutes were used?: The total amount due is:$ 62.49