//Cameron Pham CS1A Chapter 4, P. 226, #23
//
/******************************************************************************
* Calculate Internet Bill
* ______________________________________________________________________________
* This program accepts a character for the internet plan package and accpets an
* integer value for the amount of hours spent. It calculates the bill.
* ______________________________________________________________________________
* INPUT
* Internet package plan
* Hours of internet spent
* Price of internet package plan
*
* OUTPUT
* Total price of the bill
*******************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
char package;
double hours;
double bill = 0.0;
// Ask the user which package they purchased
cout << "Select your internet plan (A, B, or C).\n";
cin >> package;
cout << "You have internet plan " << package << ".\n";
// Validate the package
if (package != 'A' && package != 'B' && package != 'C')
{
cout << "Error: Invalid package. Please select A, B, or C." << endl;
return 0;
}
// Ask how many hours were used
cout << "Enter the number of hours used.\n";
cin >> hours;
// Validate the number of hours
if (hours < 0 || hours > 744)
{
cout << "Error: Hours must be between 0 and 744." << endl;
return 0;
}
else
{
cout << "You used " << hours << " hours.\n";
}
// Calculate the bill based on the package
if (package == 'A')
{
bill = 9.95;
if (hours > 10)
{
bill += (hours - 10) * 2.00;
}
}
else if (package == 'B')
{
bill = 14.95;
if (hours > 20)
{
bill += (hours - 20) * 1.00;
}
}
else if (package == 'C')
{
bill = 19.95;
}
// Display the total bill
cout << fixed << setprecision(2);
cout << "Total amount due for this month's internet bill: $" << bill;
cout << endl;
return 0;
}