//Diego Martinez CSC5 Chapter 4, P.226,#23
/*******************************************************************************
* CALCULATE MONTHLY INTERNET BILL
* ______________________________________________________________________________
* This program calculates a customer's monthly Internet bill based on the subsc-
* ription package they selected and the number of hours they used during the
* month.
*
* Computation is based on the Formula:
* Package A : Base fee includes 10 hours, extra hours are charged
* Package B : Base fee includes 20 hours, extra hours are charged
* Package C : Flat rate with unlimited access (no extra charges)
*______________________________________________________________________________
* INPUT
* Package Type
* Hours used
*
* OUTPUT
* Total monthly bill
*******************************************************************************/
#include <iostream>
#include <cctype>
using namespace std;
int main() {
char package;
int hours;
double totalBill = 0.0;
// Input package
cout << "Enter your package (A, B, C): \n";
cin >> package;
package = toupper(package);
// Validate package
if (package != 'A' && package != 'B' && package != 'C'){
cout << "Invalid package selection.\n";
return 1;
}
// Input hours used
cout << "Enter number of hours used: \n";
cin >> hours;
// Validate hours
if (hours < 0 || hours > 744) {
cout << "Invalid number of hours. Must be between 0 and 744.\n";
return 1;
}
// Calculate bill
switch (package) {
case 'A':
totalBill = 9.95;
if (hours > 10)
totalBill += (hours - 10) * 2.0;
break;
case 'B':
totalBill = 14.95;
if (hours > 20)
totalBill += (hours - 10) * 1.0;
break;
case 'C':
totalBill = 19.95;
break;
}
// Output result
cout << "Your total monthly bill is: $" << totalBill << endl;
return 0;
}