Algorithm 1: Determine Tip Amount input: Restaurant Type Rtype. Cost of Meal Cos
ID: 3600684 • Letter: A
Question
Algorithm 1: Determine Tip Amount input: Restaurant Type Rtype. Cost of Meal Cost, No. of People N, Service Type Stype output: Tip Amount tipAmount begin tipAmount 0 if Rype Diner then tipArnount 0.12 * Cost tipAmount 0.15 * Cost tip)Amount 0.20 * Cost else if Rtype Good Restaurant then else if Rtype Fancy Restaurant then if Stype = Poor then L tipAmount tipAmount-0012 * Cost tipAmount tipAmount + 0.02 * Cost tipAmount tipAmount + 0.03 * Cost tipAmount tipAmount + 0.05 * Cost else if Stype-Ercellent then if N26 &&N; 10 then else if N >10 thenExplanation / Answer
Python implementation of the above algorithm in Python 3
Please provide feedback if you like the solution
rType=input("Enter Restaurant type ")
cost=int(input("Enter cost of meal "))
N=int(input("Enter No. of people "))
sType=input("Enter service type ")
tipAmount=0
if rType.lower()=="Diner".lower():
tipAmount=0.12*cost
elif rType.lower()=="Good Restaurant".lower():
tipAmount=0.15*cost
elif rType.lower()=="Fancy Restaurant".lower():
tipAmount=0.20*cost
if sType.lower()=="Poor".lower():
tipAmount=tipAmount-0.02*cost
elif sType.lower()=="Excellent".lower():
tipAmount=tipAmount+0.02*cost
if N>= 6 and N<=10 :
tipAmount=tipAmount+0.03*cost
elif N>10:
tipAmount=tipAmount+0.05*cost
print("Tip Amount "+str(tipAmount))
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.