fork download
  1. //Jacob Silvestre CSC5 Chapter 2, P. 81, #4
  2. //
  3. /**************************************************************
  4.  *
  5.  * DETERMINE RESTAURANT BILL
  6.  * ____________________________________________________________
  7.  * This program the tax and tip on $44.50 meal with a 6.75
  8.  * percent tax rate and 15 percent tip of the total after
  9.  * adding tax.
  10.  *
  11.  * Computation is based on the formula:
  12.  * tax = 44.50 * .065
  13.  * tip = (44.50 + tax) * .15
  14.  * bill = 44.50 + tax + tip
  15.  * ____________________________________________________________
  16.  * INPUT
  17.  * 44.50 : meal cost
  18.  * .0675 : tax rate
  19.  * .15 : tip rate
  20.  *
  21.  * OUTPUT
  22.  * mealCost: meal cost
  23.  * tax : tax amount
  24.  * tip : tip amount
  25.  * bill : restaurant bill
  26.  *
  27.  **************************************************************/
  28. #include <iostream>
  29. #include <iomanip>
  30. using namespace std;
  31. int main ()
  32. {
  33. double mealCost; //OUTPUT - Meal cost
  34. double tax; //OUTPUT - Tax amount
  35. double tip; //OUTPUT - Tip amount
  36. double bill; //OUTPUT - Restaurant bill
  37.  
  38. //
  39. // Initialize Program Variables
  40. mealCost = 44.50;
  41.  
  42. //
  43. // Calculate Tax
  44. tax = mealCost * .0675;
  45.  
  46. //
  47. // Calculate Tip
  48. tip = (mealCost + tax) * .15;
  49.  
  50. //
  51. // Calculate Restaurant Bill
  52. bill = mealCost + tip + tax;
  53.  
  54. //
  55. // Output Result
  56. cout << "Meal cost: $" << mealCost << endl;
  57. cout << "Tax amount: $" << tax << endl;
  58. cout << "Tip amount: $" << tip << endl;
  59. cout << "Restaurant bill: $" << bill << endl;
  60.  
  61. return 0;
  62. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Meal cost: $44.5
Tax amount: $3.00375
Tip amount: $7.12556
Restaurant bill: $54.6293