//Xinnuo Wang CS1A chapter 4, p.226 #23
//
/*******************************************************************************
*
* Caculate bills under different subscription packages
* _____________________________________________________________________________
* This program accepts hours and packages to caculate the bills.
*
* Computation is based on the formula:
* Bills = basic bills + extra bills
* _____________________________________________________________________________
* INPUT
* Basic Bills : The basic bills in limited time
* Extra Bills : The extra bills pay for excessive time
* Hours : Used hours in a month
* Choice : The different subscription packages for customers
* OUTPUT
* Total bills : The total bills in a month
*
******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
float hours; //INPUT - Used hours in a month
float basicBills; //INPUT - The basic bills in limited time
float extraBills; //INPUT - The extra bills pay for excessive time
int choice; //INPUT - The different subscription packages for customers
float totalBills; //OUTPUT - The total bills in a month
cout <<"===== MANU ====="<<endl;
cout <<"1. Package A"<<endl;
cout <<"2. Package B"<<endl;
cout <<"3. Package C"<<endl;
//
//Data Input
cout<<"Enter choice"<<endl;
cin>>choice;
cout <<"Enter hours"<< endl;
cin>>hours;
//
//Check validation
if(hours>744)
{
cout<<"Invalid time"<< endl;
return 0;
}
//
//Output
switch(choice)
{
case 1:
if(hours<=10)
{
totalBills = 9.95;
cout << "The total bills are: $" <<totalBills <<endl;
}
else
{
totalBills = 9.95 +(hours - 10) *2;
cout << "The total bills are: $" <<totalBills <<endl;break;
}
case 2:
if(hours<=20)
{
totalBills = 14.95;
cout << "The total bills are: $" <<totalBills <<endl;
}
else
{
totalBills = 14.95 +(hours - 20) *1;
cout << "The total bills are: $" <<totalBills <<endl;break;
}
case 3:
{
totalBills = 19.95;
cout << "The total bills are: $" <<totalBills <<endl;break;
}
default:
cout<<"Invalid choice"<< endl;
}
return 0;
}