drinks = {
"espresso":{
"Water" : 100,
"Milk" : 0,
"Coffee" : 18,
"Money": 1.50
},
"latte" : {
"Water" : 200,
"Milk" : 24,
"Coffee" : 150,
"Money": 2.50
},
"cappuccino":{
"Water" : 250,
"Milk" : 24,
"Coffee" : 100,
"Money" : 3.00
},
"resources" :{
"Water": 2000,
"Milk": 700,
"Coffee": 350,
"Money":0
}
}
def report():
print(f"Water : {drinks["resources"]["Water"]}ml")
print(f"Milk : {drinks["resources"]["Milk"]}ml")
print(f"Coffee : {drinks["resources"]["Coffee"]}g")
print(f"Money : ${drinks["resources"]["Money"]}")
def count_money(item_price, item_name):
print(f"Please enter currency required for purchase : {item_price}")
pennies = float(0.01) * float(input("Insert amount of pennies: "))
nickels = float(0.05) * float(input("Insert amount of nickels: "))
dimes = float(0.10) * float(input("Insert amount of dimes: "))
quarters = float(0.25) * float(input("Insert amount of quarters: "))
total_money = pennies+nickels+dimes+quarters
change = round((total_money - item_price),2)
if total_money < item_price:
print("Sorry insufficient currency , you will be refunded and returned
to the menu now.")
mainloop()
else:
print(f"Here's your change {change}, Enjoy your
{item_name.title()}")
#Process user input
def drinks_request(drink):
if drink == "report":
report()
mainloop()
elif drink == "espresso" or drink == "latte" or drink == "cappuccino":
if drinks["resources"]["Water"] < drinks[drink]["Water"]:
print("Sorry, insufficient water for that order")
mainloop()
elif drinks["resources"]["Milk"] < drinks[drink]["Milk"]:
print("Sorry, insufficient milk for that order")
mainloop()
elif drinks["resources"]["Coffee"] < drinks[drink]["Coffee"]:
print("Sorry, insufficient coffee for that order")
mainloop()
else:
count_money(drinks[drink]["Money"],drink)
drinks["resources"]["Water"] -= drinks[drink]["Water"]
drinks["resources"]["Milk"] -= drinks[drink]["Milk"]
drinks["resources"]["Coffee"] -= drinks[drink]["Coffee"]
drinks["resources"]["Money"] += drinks[drink]["Money"]
mainloop()
else:
print("Sorry we don't have that yet. ")
mainloop()
def mainloop():
user_choice = input("What would you like? (Espresso/Latte/Cappuccino)
").lower()
if user_choice == "off":
print("Thank you for using our services. Come again!")
return 0
else:
drinks_request(user_choice)
mainloop()