Answer:
d = {"bad": 5, "good": 15, "excellent": 20}
meal_price = float(input("Enter meal price: "))
service = input("Choose level of service [bad, good, excellent]: ")
tip = meal_price * d[service] / 100
total = meal_price + tip
print("The tip for", service, "service is %", d[service], " which is $", tip)
print("The total price is $", total)
Step-by-step explanation:
*The code is in Python.
Create a dictionary that maps the level of services to tip percentages. Note that a dictionary is used to map key and value pairs. In this case, the level of services is mapped to percentages. "bad" is mapped to 5, "good" is mapped to 15, and "excellent" is mapped to 20
Ask the user to enter the meal_price
Ask the user to choose the level of service
Calculate the tip, multiply the meal_price by percentage of the tip / 100. Note that to get the value of the level of service in the dictionary, you need to write the dictionary name, brackets and inside the brackets you need to specify the key (in this case, the key is the service)
Calculate the total price, add the meal price and tip
Print the tip percentage, tip and total