(Financial application: calculate tips) Write a program that reads the subtotal and the gratuity rate and computes the gratuity and total. For example, if the user enters 10 for the subtotal and 15% for the gratuity rate, the program displays 1.5 as the gratuity and 11.5 as the total. Here is a sample run:
Enter the subtotal and a gratuity rate:15.69, 15
The gratuity is 2.35 and the total is 18.04
The below program reads the subtotal and the gratuity rate and computes the gratuity and total:
CODE WITH COMMENTS:
subtotal=float(input("enter the value of subtotal:")) #enter the input value subtotal
gratuity_rate=float(input("enter the value of gratuity rate:")) #enter another input value gratuity rate
gratuity=(gratuity_rate/100)*subtotal #formula for gratuity
total=gratuity+subtotal #formula for total
print("the gratuity is",int(gratuity*100)/100,"and the total is",int(total*100)/100 ) #print the required output
OUTPUT:
enter the value of subtotal:15.69
enter the value of gratuity rate:15
the gratuity is 2.35 and the total is 18.04
enter the value of subtotal:10
enter the value of gratuity rate:15
the gratuity is 1.5 and the total is 11.5