fork download
  1. //Amari Mosley CSC5 Chapter 2, P. 81, #4
  2. //
  3. /**************************************************************
  4.  *
  5.  * RESTAURANT BILL CALCULATION
  6.  * ____________________________________________________________
  7.  * This program will compute the tax and tip on a restaurant bill for a patron with a
  8. $44.50 meal charge.
  9.  
  10.  * Calculation is based on the following formulas:
  11.   TaxAmount = MealCost * TaxRate // Finds just the tax amount
  12. BillWithTax = MealCost + TaxAmount // Finds the bill with tax included
  13. TipCompute = BillWithTax * TipRate // Finds just the tip amount
  14. TotalBill = BillWithTax + TipCompute //Finds total bill with tax and tip included
  15.  * ____________________________________________________________
  16.  * INPUT
  17.  * MealCost : The original cost of the meal ($44.50)
  18.  * TaxRate : The state tax rate (6.75%)
  19.  * TipRate : The tip percentage (15%)
  20.  *
  21.  * OUTPUT
  22.  * TaxAmount : Calculated tax amount
  23.  * BillWithTax : Meal cost plus tax
  24.  * TipCompute : Calculated tip amount
  25.  * TotalBill : Final total including tax and tip
  26.  *
  27.  **************************************************************/
  28. #include <iostream>
  29. #include <iomanip>
  30. using namespace std;
  31.  
  32. // Defining Main Function
  33. int main()
  34.  
  35. {
  36. // Defining Variable Values
  37. double MealCost = 44.50;
  38. double TaxRate = 0.0675;
  39. double TipRate = 0.15;
  40.  
  41. double TaxAmount, BillWithTax, TipCompute, TotalBill;
  42.  
  43. // Computations Step by Step
  44. TaxAmount = MealCost * TaxRate; // Finds just the tax amount
  45. BillWithTax = MealCost + TaxAmount; // Finds the bill with tax included
  46. TipCompute = BillWithTax * TipRate; // Finds just the tip amount
  47. TotalBill = BillWithTax + TipCompute; // Finds total bill with tax and tip included
  48.  
  49. //Final Bill Display
  50. cout << "Meal Cost: $" << MealCost << endl;
  51. cout << "Tax Amount: $" << TaxAmount << endl;
  52. cout << "Tip Amount: $" << TipCompute << endl;
  53. cout << "Total Bill: $" << TotalBill << endl;
  54.  
  55. return 0;
  56. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Meal Cost:   $44.5
Tax Amount:  $3.00375
Tip Amount:  $7.12556
Total Bill:  $54.6293