fork download
  1. //George Molinero csc5 chapter 4, P. 226, #23
  2. //
  3. /*******************************************************************************
  4.  *
  5.  * Compute Internet Bill
  6.  * _____________________________________________________________________________
  7.  * This program computes the total of an intertnet Bill
  8.  * _____________________________________________________________________________
  9.  * INPUT
  10.  * Package : Package selected
  11.  * hours : Amount of hours used
  12.  *
  13.  * OUTPUT
  14.  * ExtraHours : Amount of hours past limit
  15.  * Total Bill Amount Displayed
  16.  ******************************************************************************/
  17. #include <iostream>
  18. using namespace std;
  19.  
  20. int main()
  21. {
  22. const float PackA = 9.95;
  23. const float PackB = 14.95;
  24. const float PackC = 19.95;
  25. char Package;
  26. int hours;
  27. int ExtraHours = 0;
  28.  
  29. cout << "What package have you purchased? " << endl;
  30. cin >> Package;
  31.  
  32. if(Package == 'A' || Package == 'a' || Package == 'B' || Package == 'b' ||
  33. Package == 'c' || Package == 'C')
  34. {
  35. switch (Package)
  36. {
  37. case 'A':
  38. case 'a': cout << "How many hours were used? " << endl;;
  39. cin >> hours;
  40. if (hours <= 744)
  41. {
  42. if (hours > 10)
  43. {
  44. ExtraHours = hours - 10.0;
  45. cout << "Your total is $" << (ExtraHours * 2.00)
  46. + (10 * PackA);
  47. }
  48. else
  49. cout << "Your total is $" << hours * PackA;
  50. }
  51. break;
  52.  
  53. case 'B':
  54. case 'b': cout << "How many hours were used? ";
  55. cin >> hours;
  56. if (hours <= 744)
  57. {
  58. if (hours > 10)
  59. {
  60. ExtraHours = hours - 10.0;
  61. cout << "Your total is $" << (ExtraHours * 1.00)
  62. + (10 * PackB);
  63. }
  64. else
  65. cout << "Your total is $" << hours * PackB;
  66. }
  67. break;
  68. case 'C':
  69. case 'c': cout << "How many hours were used? ";
  70. cin >> hours;
  71. if (hours <= 744)
  72. cout << "Your total is $" << hours * PackC;
  73. break;
  74. }
  75. }
  76. return 0;
  77. }
Success #stdin #stdout 0s 5296KB
stdin
c
11
stdout
What package have you purchased? 
How many hours were used? Your total is $219.45