//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.
*
* This program produces a monthly Internet bill. The Internet bill is based on
* a selected subscription package, and the number of hours consumed during the
* billing period.
*
* 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
* Base fee
* Flat rate
* Package hours
* Hours used
* Base fee
* Extra hours
*
* OUTPUT
* Total monthly bill
*******************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
// total = ComputePackagePrice(package, hours);
float ComputePackagePrice(char package, float hours);
int main() {
char package;
float hours;
float total;
// Ask for package
cout << "Enter your package (A, B, or C): \n";
cin >> package;
// Validate Package
while (package != 'A' && package != 'B' && package != 'C' &&
package != 'a' && package != 'b' && package != 'c') {
cout << "Invalid package. Enter A, B, or C: \n";
cout << "Invalid package. Cannot calculate bill." << endl;
cout << "Enter your package (A, B, or C): \n";
cin >> package;
}
cout << "Line #52: " << package << endl;
// Ask for hours
cout << "Enter number of hours used: \n";
cin >> hours;
// Only accept valid hours
while (hours < 0 || hours > 744) {
cout << "Invalid hours. Enter a value between 0 and 744: \n";
cin >> hours;
}
cout << "Line #63: " << hours << endl;
// total = ComputePackagePrice(package, hours);
// Calculate total bill based on package
switch (package) {
case 'A': case 'a':
total = 9.95;
if (hours > 10)
total += (hours - 10) * 2.00;
break;
case 'B': case 'b':
total = 14.95;
if (hours > 20)
total += (hours - 20) * 1.00;
break;
case 'C': case 'c':
total = 19.95; // unlimited
break;
}
// Display total
cout << fixed << setprecision(2);
cout << "Total amount due: $" << total << endl;
return 0;
}
float ComputePackagePrice(char package, float hours)
{
}