Answer:
Since Python is a scripting language, here is code in python.
#prompt user to give check
amount=float(input("Please Enter the check:"))
#prompt user to give service
service=input("Please Enter the service (good, fair or poor):")
# calculate tip on the basis of service
if service =="good":
tip=amount*0.2
elif service=="fair":
tip=amount*0.15
elif service=="poor":
tip=amount*0.05
#calculate total
total=amount+tip
#print tip
print("tip is equal to : {} ".format(tip))
#print total
print("total of the check is : {} ".format(total))
Explanation:
Prompt user to give check and service input.After taking the input from user, based on the service tip will be calculated. if service is "good" then tip will be 20% of the check, tip will be 15% if service is "fair" and tip will be 5% if service is "poor".
Output:
Please Enter the check:125
Please Enter the service (good, fair or poor):good
tip is equal to : 25.0
total of the check is : 150.0