fork download
  1. //Andres Guzman CSC5 Chapter 2, P. 81, #4
  2. //
  3. /**************************************************************
  4. *
  5. * COMPUTE TOTAL COST OF RESTAURANT BILL
  6. * ____________________________________________________________
  7. * This program computes the total bill after taxes & tips
  8. *
  9. * Computation is based on the formulas:
  10. * tax_meal = (meal_check * tax) + meal_check
  11. * total_meal = (tax_meal * tip) + meal_check
  12. * ____________________________________________________________
  13. * INPUT
  14. * meal_check : total cost of meal
  15. * tax : tax amount
  16. * tip : tip amount
  17. * OUTPUT
  18. * total_meal : bill after taxes and tips
  19. *
  20. **************************************************************/
  21. #include <iostream>
  22. #include <iomanip>
  23. using namespace std;
  24. int main ()
  25. {
  26. double meal_check; //Input meal price
  27. double tax; //Input tax amount
  28. double tip; //Input tip amount
  29. double tax_meal; //Output meal after taxes
  30. double total_meal; //Output taxxed meal after tips
  31. //
  32. //Initializing Variables
  33. meal_check = 44.50;
  34. tax = 0.0675;
  35. tip = 0.15;
  36. //
  37. //Computing total functions
  38. tax_meal = (meal_check * tax) + meal_check;
  39. total_meal = (tax_meal * tip) + tax_meal;
  40. //
  41. //Output Result
  42. cout << fixed << setprecision(2) << "Meal Cost: $" << meal_check << endl;
  43. cout << "Tax Amount: " << tax * 100 << "%" << endl;
  44. cout << fixed << setprecision(0) << "Tip Amount: " << tip * 100 << "%" <<
  45. endl;
  46. cout << fixed << setprecision(2) << "Total Cost: $" << total_meal << endl;
  47. return 0;
  48. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Meal Cost: $44.50
Tax Amount: 6.75%
Tip Amount: 15%
Total Cost: $54.63