144k views
7 votes
Create a program that calculates the tip and total for a meal at a restaurant. Type the code into an IDLE IDE editor window and save the finished code as a .py source code file. Remember that the text output from the IDLE shell window will be saved to a Word document.

User Jveldridge
by
3.3k points

1 Answer

9 votes

Missing details:

The formula for calculating the tip amount is:

tip = cost of meal * (tip percent / 100)

  • The program should accept decimal entries like 52.31 and 15.5.
  • Assume the user will enter valid data.
  • The program should round the results to a maximum of two decimal places.

Answer:

In Python:

print("Tip Calculator")

cost_meal = float(input("Enter Cost of Meal: "))

tip_percent = float(input("Enter Tip Percent: "))

tip_amount = cost_meal * tip_percent / 100

total_amount = tip_amount + cost_meal

print("Tip amount: "+str(round(tip_amount,2)))

print("Total amount: "+str(round(total_amount,2)))

Step-by-step explanation:

This line prints the string "Tip "Calculator"

print("Tip Calculator")

This lime prompts user for cost of meal

cost_meal = float(input("Enter Cost of Meal: "))

This lime prompts user for tip percemtage

tip_percent = float(input("Enter Tip Percent: "))

This line calculates the tip amount

tip_amount = cost_meal * tip_percent / 100

This line calculates the total amount

total_amount = tip_amount + cost_meal

This line prints the tip amount

print("Tip amount: "+str(round(tip_amount,2)))

This line prints the total amount

print("Total amount: "+str(round(total_amount,2)))

Follow these steps to complete the solution

  • Copy the code in the answer section.
  • Save as .py
  • Run the program
  • Save the screenshots of the program result in a word document
User Snivs
by
3.9k points