213k views
4 votes
Write a Python 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, then calculate the amounts of a 20 percent tip and 6 percent sales tax. Display each of these amounts and the total. Submit your completed .py file.

User Vonovak
by
4.7k points

1 Answer

6 votes

charge = float(input("Enter the cost of the meal: $"))

tip = charge*0.2

tax = charge*0.06

print("A 20% tip would be: $"+str(tip))

print("A 6% sales tax would be: $"+str(tax))

print("The total would be: $"+str(charge+tip+tax))

I wrote my code in python 3.8. I hope this helps.

User Deian
by
4.6k points