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