1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81

void CalculateBill( int inAdults, int inChildren, bool inDeluxeMeal, bool inWeekend,
double inDeposit )
{
if( displayBill )
{
const double ADULT_DELUXE = 25.80;
const double ADULT_STANDARD = 21.75;
const double TIP_TAX_RATE = .18;
const double WEEKEND_SURCHARGE = .07;
double childDeluxe = ADULT_DELUXE * .6;
double childStandard = ADULT_DELUXE * .6;
double tACost = 0;
double tCCost = 0;
double tTCost = 0;
double tSurcharge = 0;
double tTaxTip = 0;
double tPCost = 0;
double tBalanceDue = 0;
double tDiscount = 0;
double tDiscountBalance = 0;
string tDiscountPercent = "";
if( inDeluxeMeal )
{ /* Total cost of all the deluxe meals. */
tACost = ADULT_DELUXE * inAdults;
tCCost = childDeluxe * inChildren;
}
else
{ /* Total cost of all the standard meals. */
tACost = ADULT_STANDARD * inAdults;
tCCost = childStandard * inChildren;
}
// Calculations
tTCost = tACost + tCCost; /* Total cost of the food. */
if( inWeekend == true )
{
tSurcharge = tTCost * WEEKEND_SURCHARGE; /* Calculate the surcharge */
}
tTaxTip = (tTCost + tSurcharge) * TIP_TAX_RATE; /* Calculate the tax and tip. */
tPCost = tTCost + tTaxTip + tSurcharge; /* Add up total cost, tax, tip and surcharge. */
// Calculate the available discount.
if( tPCost < 100.00 )
{
tDiscount = tPCost * .015;
tDiscountPercent = "1.5%";
}
else if( tPCost < 400.00 )
{
tDiscount = tPCost * .025;
tDiscountPercent = "2.5%";
}
else
{
tDiscount = tPCost * .035;
tDiscountPercent = "3.5%";
}
tBalanceDue = tPCost  inDeposit; /* Calculate the prediscount balance due. */
tDiscountBalance = tBalanceDue  tDiscount; /* Calculate the postdiscount balance due. */
// Pass calculations to the PrintResults function.
if( saveDataFile )
{
PrintResults( outData, inAdults, inChildren, inDeluxeMeal,
inWeekend, inDeposit, ADULT_DELUXE, ADULT_STANDARD,
childDeluxe, childStandard, tACost, tCCost, tTCost, tSurcharge,
tTaxTip, tPCost, tBalanceDue, tDiscount, tDiscountPercent,
tDiscountBalance );
}
if( displayBill)
{
PrintResults( cout, inAdults, inChildren, inDeluxeMeal, inWeekend,
inDeposit, ADULT_DELUXE, ADULT_STANDARD, childDeluxe,
childStandard, tACost, tCCost, tTCost, tSurcharge, tTaxTip,
tPCost, tBalanceDue, tDiscount, tDiscountPercent,
tDiscountBalance );
}
}
}
