//Max Kichuk CS1A Chapter 4, P. 226, #23
//
/****************************************************************
*
* CALCULATES MONTHLY BILL FOR SERVICE PROVIDER
* ______________________________________________________________
* Asks the user to enter the hours used and what
* package the user has selected. Displays the total amount due
* according to their hours and package.
*
* CALCULATIONS MADE BY:
*
* Package A: For $9.95 per month 10 hours of access are provided. Additional hours
* are $2.00 per hour.
*
* Package B: For $14.95 per month 20 hours of access are provided. Additional
* hours are $1.00 per hour.
*
* Package C: For $19.95 per month unlimited access is provided
* ______________________________________________________________
*
* INPUT
* packagePlan : package plan user has selected
* hoursUsed : number of hours used on plan
*
* OUTPUT
* totalCost : total cost on plan A/B/C
*
**************************************************************/
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main() {
//Declaring program variables
char packagePlan; // INPUT : plan user is on
float hoursUsed; // INPUT : hours used on plan
float totalCost; // OUTPUT : total cost of hours
// INPUT : Initialize variables
cout << "Enter the package you are on (A/B/C) and your hours used ";
cout << "separated by a space.\n";
cin >> packagePlan >> hoursUsed;
totalCost = 0.0;
// OUTPUT : Display the price
switch(packagePlan)
{
case 'a':
case 'A': cout << "You are on Package A.\n";
totalCost += 9.95;
if (hoursUsed > 10) {
hoursUsed-=10;
totalCost += hoursUsed*2;
}
cout << "You owe $" << setprecision(2) << fixed << totalCost << ".";
break;
case 'b':
case 'B': cout << "You are on Package B.\n";
totalCost += 14.95;
if (hoursUsed > 20) {
hoursUsed-=20;
totalCost += hoursUsed;
}
cout << "You owe $" << setprecision(2) << fixed << totalCost << ".";
break;
case 'c':
case 'C': cout << "You are on Package C.\n";
totalCost += 19.95;
cout << "You owe $" << setprecision(2) << fixed << totalCost << ".";
break;
}
return 0;
}