The program that you create for this exercise will begin by reading the cost of a meal ordered at a restaurant from the user. Then your program will compute the tax and tip for the meal. Use your local tax rate when computing the amount of tax owing. Compute the tip as 18 percent of the meal amount (without the tax). The output from your program should include the tax amount, the tip amount, and the grand total for the meal including both the tax and the tip. Format the output so that all of the values are displayed using two decimal places.

Respuesta :

Answer:

Explanation

If I were calculating a tip at a restaurant using the same syntax, it would have been. meal ... New value of meal is double meal times tax. you're saying: (meal + meal) * tax but meal + meal * tax is calculated in the following order meal + (meal * tax) ... eh? ;) The exercise implied it was just reading the equation from right to left.

The program is a sequential program; as such, it does not require loops or conditional statements.

The program in Python, where comments are used to explain each line is as follows:

#This gets input for the cost of the meal

cost = float(input("Cost: "))

#This initializes the local rate tax to 7.25%

local_rate_tax = 0.0725

#This initializes the tip to 18%

tip = 0.18

#This calculates the tax amount

taxAmount = cost * local_rate_tax

#This calculates the tip amount

tipAmount = cost * tip

#This calculates the grand total

grand = cost + taxAmount + tipAmount

#This prints the tax amount

print("Tax amount: {:.2f}".format(taxAmount))

#This prints the tip amount

print("Tip: {:.2f}".format(tipAmount))

#This prints the grand total

print("Grand total: {:.2f}".format(grand))

All outputs are formatted to 2 decimal places.

See attachment for sample run

Read more about similar programs at:

https://brainly.com/question/23954622

Ver imagen MrRoyal