//Charlotte Davies-Kiernan CS1A Chapter 4 P. 226 #23
//
/******************************************************************************
*
* Compute Subscription Payment
* ____________________________________________________________________________
* This program will prompt users to select a package they used, enter the
* hours it was used for and then it calculates the total monthly bill based
* on the package
*
* Formulas that will be used:
* total += (hours - 10) * 2.00
* total += (hours - 20) * 1.00
*_____________________________________________________________________________
* INPUT
* package //users choice of package used
* hours //users amount of hours used
*
* OUTPUT
* total //total based of package used and hours used
*****************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
char package; //INPUT - user's choice of package
float hours; //INPUT - user's amount of hours used
float total; //OUTPUT - user's total amount to pay
//
//Prompt user for package
cout << "Enter your subscription package (A, B, or C): " << endl;
cin >> package;
//
//Validate package input
if (package != 'A' && package != 'B' && package != 'C'){
cout << "Invalid package selected. Please choose A, B, or C." << endl;
return 1;
}
//
//Get user's hours used
cout << "Enter the number of hours used (0-744): " << endl;
cin >> hours;
//
//Validate hours input
if (hours < 0 || hours > 744) {
cout << "Invalid number of hours. Please enter a value between 0 and 744" << endl;
return 1;
}
//
//Calculate bill based on package selected
switch (package) {
case 'A':
total = 9.95;
if (hours > 10)
total += (hours - 10) * 2.00;
break;
case 'B':
total = 14.95;
if (hours > 20)
total += (hours - 20) * 1.00;
break;
case 'C':
total = 19.95; //unlimited
break;
}
//
//Display the result
cout << fixed << setprecision (2);
cout << "Total amount due: $" << total << endl;
return 0;
}