11.4k views
0 votes
Write a program that reads the subtotal and the gratuity rate, then computes the gratuity and total. For example, if the user enters 10 for subtotal and 15% for gratuity rate, the program displays $1.5 as gratuity and $11.5 as total.

User Ziv
by
8.1k points

1 Answer

2 votes

Answer:

subtotal = float(input("Subtotal: "))

gratuity_rate = float(input("Gratuity Rate: "))

gratuity = subtotal * gratuity_rate / 100

total = subtotal + gratuity

print("Gratuity is $" + str(gratuity))

print("Total is $" + str(total))

Step-by-step explanation:

*The code is in Python.

Ask the user to enter subtotal and gratuity_rate

Calculate the gratuity, multiply subtotal and gratuity_rate and divide the result by 100

Calculate the total, sum the subtotal and gratuity

Print the gratuity and total

User Blejzz
by
8.6k points