//Cecilia Rangel CSC5 Chapter 4, P. 225, #23
//
/**************************************************************
*
* Computing mobile service charge
* ____________________________________________________________
* This program computes which number is the smaller or bigger
* out of two numbers prompted by the user
*
* Computation is based on the following formulas:
* Additional (Add'l) minutes = Total minutes - Minutes included
* Charge = Base charge + Add'l minutes * Add'l minute rate
*___________________________________________________________
* CONSTANTS
* packageA : Menu choice for Package A
* packageB : Menu choice for Package B
* packageC : Menu choice for Package C
*
* INPUT
* packageChoice : User choice among menu options
* totalMin : Number of minutes used by user
* base_A : Base charge for Package A
* minIncl_A : Number of minutes included with base charge
* of Package A
* addlMinRate_A : Rate of charge per add'l minute for Package A
* base_B : Base charge for Package B
* minIncl_B : Number of minutes included with base charge
* of Package B
* addlMinRate_B : Rate of charge per add'l minute for Package B
* base_C : Base charge for Package C
*
* OUTPUT
* addlMin : Add'l minutes to be charged extra
* charge : Total charge for service
*
**************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
const int packageA = 1; // CONSTANT - Menu choice for Package A
const int packageB = 2; // CONSTANT - Menu choice for Package B
const int packageC = 3; // CONSTANT - Menu choice for Package C
int packageChoice; // INPUT - User choice among menu options
int totalMin; // INPUT - Number of minutes used by user
double base_A = 39.99; // INPUT - Base charge for Package A
int minIncl_A = 450; // INPUT - Number of minutes included with
// base charge of package A
double addlMinRate_A = 0.45; // INPUT - Rate of charge per add'l minute
// for Package A
double base_B = 59.99; // INPUT - Base charge for Package B
int minIncl_B = 900; // INPUT - Number of minutes included with
// base charge of Package B
double addlMinRate_B = 0.40; // INPUT - Rate of charge per add'l minute
// for Package B
double base_C = 69.99; // INPUT - Base charge for Package A
int addlMin; // OUTPUT - Add'l minutes to be charged extra
double charge; // OUTPUT - Total charge for service
//
// Prompt User to Specify Package and Minutes Used
cout << "1. Package A: $39.99/mo for 450 min. + $0.45/add'l min." << endl;
cout << "2. Package B: $59.99/mo for 900 min. + $0.40/add'l min." << endl;
cout << "3. Package C: $69.99/mo for Unlimited min." << endl << endl;
cout << "Which of the above packages are you subscribed to? (1-3): ";
cin >> packageChoice;
cout << endl << left;
cout << setw(56) << "How many minutes did you use?" << ": ";
cin >> totalMin;
cout << right;
cout << endl;
//
// Calculate Monthly Charge Based on Subscription; Output Results
if (totalMin >= 0)
{
switch (packageChoice)
{
case packageA:
addlMin = totalMin - minIncl_A;
charge = base_A + addlMin * addlMinRate_A;
cout << "Total charge: $" << charge;
break;
case packageB:
addlMin = totalMin - minIncl_B;
charge = base_B + addlMin * addlMinRate_B;
cout << "Total charge: $" << charge;
break;
case packageC:
charge = base_C;
cout << "Total charge: $" << charge;
break;
default:
cout << "You must select your package by entering 1, 2, or 3.";
}
}
else
cout << "Your number of used minutes must be at least 0.";
return 0;
}