fork download
  1. /*******************************************************************************************
  2. * Name: Marcelo Vargas
  3. * Chapter 2 Homework
  4. * Class: CSC5
  5. * #4
  6. *
  7. * Restaurant Bill
  8. *
  9. * This program calculates the tax, and tip on a $44.50 meal then display's the information
  10. * __________________________________________________________________________________________
  11. * INPUT
  12. * price = the price of the meal purchased ($44.50)
  13. * tax = the amount taxed on the meal (%6.75)
  14. * tip = the amount tipped on the mea (%15)
  15. *
  16. * OUTPUT
  17. * total = :sum of price, tax and tip
  18. *
  19. ********************************************************************************************/
  20. //importing "iostream" from stream library
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. int main()
  25. {
  26. // Declare variables
  27. float price = 44.50; //Price of the meal
  28. float tax = 6.75; //Tax percentage
  29. float tip = 15.00; //Tip percentage
  30. float total; //Sum of price, tax, and tip
  31.  
  32. //calculates tax & tip, store sum as total
  33. total = price * (1 + tax / 100 + tip / 100);
  34.  
  35. //Display total of the calculation
  36. cout << "the total is " << total << endl;
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
the total is 54.1787