Write a program to generate a restaurant bill using Nested if –else for 3 items with sub choices and calculate the amount.
Answers
choice = "Yes"
while choice == "Yes":
print("1. Breakfast", "2. Lunch", "3. Dinner", sep = "\n")
c = input("State the choice of your order: ")
print()
if c == "1":
a = int(input("Enter your amount of order: "))
if a > 500:
print("You receive a discount of 15%.")
ta = a - (a*0.15)
print(ta, "is your payable amount.")
else:
print("You receive a discount of 5%.")
ta = a - (a*0.05)
print(ta, "is your payable amount.")
elif c == "2":
a = int(input("Enter your amount of order: "))
if a > 500:
print("You receive a discount of 15%.")
ta = a - (a*0.15)
print(ta, "is your payable amount.")
else:
print("You receive a discount of 5%.")
ta = a - (a*0.05)
print(ta, "is your payable amount.")
elif c == "3":
a = int(input("Enter your amount of order: "))
if a > 500:
print("You receive a discount of 15%.")
ta = a - (a*0.15)
print(ta, "is your payable amount.")
else:
print("You receive a discount of 5%.")
ta = a - (a*0.05)
print(ta, "is your payable amount.")
print()
choice = input("Next payment? [Yes/No]: ")
print()
Answer:
choice = "Yes"
while choice == "Yes":
print("1. Breakfast", "2. Lunch", "3. Dinner", sep = "\n")
c = input("State the choice of your order: ")
print()
if c == "1":
a = int(input("Enter your amount of order: "))
if a > 500:
print("You receive a discount of 15%.")
ta = a - (a*0.15)
print(ta, "is your payable amount.")
else:
print("You receive a discount of 5%.")
ta = a - (a*0.05)
print(ta, "is your payable amount.")
elif c == "2":
a = int(input("Enter your amount of order: "))
if a > 500:
print("You receive a discount of 15%.")
ta = a - (a*0.15)
print(ta, "is your payable amount.")
else:
print("You receive a discount of 5%.")
ta = a - (a*0.05)
print(ta, "is your payable amount.")
elif c == "3":
a = int(input("Enter your amount of order: "))
if a > 500:
print("You receive a discount of 15%.")
ta = a - (a*0.15)
print(ta, "is your payable amount.")
else:
print("You receive a discount of 5%.")
ta = a - (a*0.05)
print(ta, "is your payable amount.")
print()
choice = input("Next payment? [Yes/No]: ")
print()