Skip to content

Instantly share code, notes, and snippets.

@darlingj84
Created July 11, 2012 17:48
Show Gist options
  • Save darlingj84/3091987 to your computer and use it in GitHub Desktop.
Save darlingj84/3091987 to your computer and use it in GitHub Desktop.
//Programming Assignment #8
// CellBillFun
//Author: Jess Darling
//Date: July 8, 2012
#include <stdlib.h>
#include < iostream>
#include <iomanip>
using namespace std;
const double R_Srv_Fee = 10.00;
const double P_Srv_Fee = 25.00;
const int base_R_min = 50;
const int base_Pday_min = 75;
const int base_Pnight_min = 100;
const double over_RbaseFee = .20;
const double over_PbaseDayFee = .10;
const double over_PbaseNFee = .05;
double calcRegBill (int Rmins);
double calcPremBill (int Dmins, int Nmins);
void printBill(string acctnumber, char srvtype, int totalmin, double totalDue);
int main()
{
int acctnumber;
char srvtype;
int Rmins;
int Dmins;
int Nmins;
int totalmin;
double totalDue;
cout << fixed << showpoint;
cout << setpercision (2);
cout << "Enter Account Number ( 0 to quit): " << endl;
cin >> acctnumber;
cout << endl;
cout << "Enter Service Type: R or r (Regular), P or p (Premium): " << endl;
cin >> srvtype;
cout << endl;
switch (srvtype)
{
case 'r':
case 'R':
cout << "Enter minutes used: " << endl;
cin >> Rmins;
totalDue = calcRegBill(Rmins);
totalmin = Rmins;
case 'p':
case 'P':
cout << "Enter day minutes used: " << endl;
cin >> Dmins;
cout << "Enter night minutes used: " << endl;
cin >> Nmins;
totalDue = calcPremBill(Dmins,Nmins);
totalmin = Dmins + Nmins;
}
printBill(string acctnumber, char srvtype, int totalmin, double totalDue);
system("PAUSE");
return 0:
}
double calcRegBill (int Rmins)
{
int amtDue;
if (Rmins <= base_R_min)
amtDue = R_Srv_Fee;
else
amtDue = R_Srv_Fee + ((Rmins - base_R_min) * over_RbaseFee);
return (amtDue);
}
double calcPremBill (int Dmins, int Nmins)
{
int amtDue;
if (Dmins > base_Pday_min);
amtDue = P_Srv_Fee + ((Dmins - base_Pday_min) * over_PbaseDayFee);
if (Nmins > base_Pnight_min;
amtDue = P_Srv_Fee + ((Nmins - base_Pnight_min) * over_PbaseNightFee);
else
amtDue = P_Srv_Fee;
return (amtDue);
}
void printBill(string acctnumber, char srvtype, in totalmin, double amtDue)
{
cout << "Jess Darling" << endl;
cout << "Account Number: "
<< acctnumber << endl;
cout << "Service Type: "
<<srvtype << endl;
cout << "Minutes Used: "
<< totalmin << endl;
cout << "Amount Due: $"
<<amtDue << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment