Write a program that calculates the total amount of a meal purchased at a restaurant.

Tip, Tax, and Total

Write a program that calculates the total amount of a meal purchased at a restaurant. The program should ask the user to enter the charge for the food, and then calculate the amount of a 15 percent tip and 7 percent sales tax. Display each of these amounts and the total.

Solution

#Get the total amount of meal purchase

totalMealPurchased = float(input(“Enter the charge for the food : “))

#calculate the tip(15%)

tip = totalMealPurchased * .15

#calculate the sales tax(7%)

saleTax = totalMealPurchased * .07

#calculate the total sales

totalPurchased =( totalMealPurchased + tip + saleTax )

 

#display the total amount of meal purchase

print(“Amount of the meal purchase :”,format(totalMealPurchased , ‘,.2f’))

#display the tip

print(“Amount of the tip :”,format(tip , ‘,.2f’))

#display the sales tax

print(“Amount of the sales tax :”,format(saleTax , ‘,.2f’))

#display the total purchased

 

print(“total purchased :”,format(totalPurchased , ‘,.2f’))