I am creating a simple food ordering system that cannot use for loops and arrays, lists, collections, etc. and I cannot determine why the program displays the same food items for every order. The program can take orders from 1-3 customers, with each of them ordering one main dish, side dish, and drink.
strt = int(input("1: Order\n2: Exit\n"))
if strt == 1:
print("\nMENU:")
print("Mains:\n ID Type Price")
print(
" 1 Chicken 90.00\n 2 Pork 105.00\n 3 Fish 120.00\n 4 Beef 135.00"
)
print("Sides:\n ID Type Price")
print(
" 1 Steamed Rice 20.00\n 2 Shredded Corn 35.00\n 3 Mashed Potatoes 50.00\n 4 Steam Vegetables 65.00"
)
print("Drinks:\n ID Type Price")
print(
" 1 Mineral Water 25.00\n 2 Iced Tea 35.00\n 3 Soda 45.00\n 4 Fruit Juice 55.00"
)
print(
"Enter the ID of the item you want to order. Enter 0 if you don't want an item for that category.\n"
)
cust = int(input("How many people are in your group? "))
ordr = 0
msoc = 0
pwno = 0
mprc = float(0)
sprc = float(0)
dprc = float(0)
mtot = float(0)
stot = float(0)
dtot = float(0)
while ordr != cust and cust <= 3:
ordr = ordr + 1
print(f"\nOrder {ordr}:")
if ordr <= cust or msoc == n:
main = int(input(" Main: "))
if main == 1:
mprc = float(90)
print(" Chicken")
elif main == 2:
mprc = float(105)
print(" Pork")
elif main == 3:
mprc = float(120)
print(" Fish")
elif main == 4:
mprc = float(135)
print(" Beef")
elif main == 0:
print(" None")
side = int(input(" Side: "))
if side == 1:
sprc = float(20)
print(" Steamed Rice")
elif side == 2:
sprc = float(35)
print(" Shredded Corn")
elif side == 3:
sprc = float(50)
print(" Mashed Potatoes")
elif side == 4:
sprc = float(65)
print(" Steamed Vegetables")
elif side == 0:
print(" None")
drnk = int(input(" Drink: "))
if drnk == 1:
dprc = float(25)
print(" Mineral Water")
elif drnk == 2:
dprc = float(35)
print(" Iced Tea")
elif drnk == 3:
dprc = float(45)
print(" Soda")
elif drnk == 4:
dprc = float(55)
print(" Fruit Juice")
elif drnk == 0:
dprc = float(0)
print(" None")
msoc = input("Is this order correct (y/n)? ")
if msoc == "y":
pwno = input("Proceed with the next order (y/n)? ")
if pwno == "y":
continue
elif pwno == "n":
ordr = cust
continue
elif msoc == "n":
ordr = ordr - 1
continue
cncl = input("Cancel all orders (y/n)? ")
if cncl == "y":
print("")
elif cncl == "n":
xcld = input("Exclude an item from the total (y/n)? ")
if xcld == "y":
frwo = int(input("From which order? "))
wiwe = int(input("Which item will be excluded? "))
elif xcld == "n":
print(f"\nOrder for party of {cust}")
ordr = 0
while ordr != cust and cust <= 3:
ordr = ordr + 1
print(f"Order {ordr}:")
if main == 1:
main = "Chicken"
elif main == 2:
main = "Pork"
elif main == 3:
main = "Fish"
elif main == 4:
main = "Beef"
if side == 1:
side = "Steamed Rice"
elif side == 2:
side = "Shredded Corn"
elif side == 3:
side = "Mashed Potatoes"
elif side == 4:
side = "Steamed Vegetables"
if drnk == 1:
drnk = "Mineral Water"
elif drnk == 2:
drnk = "Iced Tea"
elif drnk == 3:
drnk = "Soda"
elif drnk == 4:
drnk = "Fruit Juice"
mtot = mtot + mprc
stot = stot + sprc
dtot = dtot + dprc
print(f"Main: {main} Price: {mprc}")
print(f"Side: {side} Price: {sprc}")
print(f"Drink: {drnk} Price: {dprc}\n")
print(f"Main: {mtot}\nSide: {stot}\nDrinks: {dtot}")
elif strt == 2:
print("Thank you for using the program.")
If I order for two customers, input 1, 2, and 3 for order 1 and 3, 2, and 1 for order 2, the total only displays food items 1, 2, and 3 for both orders instead of the desired output of items 1, 2, 3 for order 1 and 3, 2, and 1 for order 2.
Actually you need sort of memory (tuple, arrays, etc.) to keep track of orders details, the reason you have same order printed is that you overwriting the variables main
, side
and drnk
every time you catch user input and discard the previous ones