Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MENU = {
- "espresso": {
- "ingredients": {
- "water": 50,
- "coffee": 18,
- },
- "cost": 1.5,
- },
- "latte": {
- "ingredients": {
- "water": 200,
- "milk": 150,
- "coffee": 24,
- },
- "cost": 2.5,
- },
- "cappuccino": {
- "ingredients": {
- "water": 250,
- "milk": 100,
- "coffee": 24,
- },
- "cost": 3.0,
- }
- }
- resources = {
- "water": 300,
- "milk": 200,
- "coffee": 100,
- }
- profit = 0
- def payment():
- print("\nPlease insert coins.\n")
- print(coffee + " price: $" + str(MENU[coffee]["cost"]))
- quarters = int(input("How many quarters?: ")) * 0.25
- # dimes = int(input("How many dimes?: ")) * 0.1
- # nickles = int(input("How many nickles?: ")) * 0.05
- # pennies = int(input("How many pennies?: ")) * 0.01
- # total = quarters + dimes + nickles + pennies
- total = quarters
- if coffee == "espresso":
- refund = total - MENU["espresso"]["cost"]
- elif coffee == "latte":
- refund = total - MENU["latte"]["cost"]
- elif coffee == "cappuccino":
- refund = total - MENU["cappuccino"]["cost"]
- if refund < 0:
- missing = refund * -1
- print(f"You need ${missing} more for your ${coffee}.")
- else:
- print(f"Your ${coffee} in on the way!")
- def resources_subtract():
- if coffee == "espresso":
- resources["water"] -= 50
- resources["coffee"] -= 18
- elif coffee == "latte":
- resources["water"] -= 200
- resources["coffee"] -= 24
- resources["milk"] -= 150
- elif coffee == "cappuccino":
- resources["water"] -= 250
- resources["coffee"] -= 24
- resources["milk"] -= 100
- def coffee_selection():
- if coffee == "report":
- print("water:", resources["water"])
- print("coffee:", resources["coffee"])
- print("milk:", resources["milk"])
- print(f"The totalal profit is: ${profit}")
- elif coffee in MENU:
- payment()
- else:
- print("error 404 coffee not found")
- def resources_check():
- enough_items = True
- missing_item = ""
- if coffee == "espresso":
- if resources["water"] < 49:
- missing_item = "water"
- elif resources["coffee"] < 17:
- missing_item = "coffe"
- elif coffee == "latte":
- if resources["water"] < 199:
- missing_item = "water"
- elif resources["coffee"] < 23:
- missing_item = "coffe"
- elif resources["milk"] < 149:
- missing_item = "milk"
- elif coffee == "cappuccino":
- if resources["water"] < 249:
- missing_item = "water"
- elif resources["coffee"] < 23:
- missing_item = "coffe"
- elif resources["milk"] < 99:
- missing_item = "milk"
- if missing_item != "":
- enough_items = False
- print("Sorry not enough " + missing_item)
- return enough_items
- is_on = True
- while is_on:
- coffee = input("\nWhat would you like? (espresso/latte/cappuccino):\n").lower()
- enough_resources = resources_check()
- if enough_resources:
- if coffee == "off":
- is_on = False
- elif coffee == "espresso":
- profit += 1.5
- elif coffee == "latte":
- profit += 2.5
- elif coffee == "cappuccino":
- profit += 3
- coffee_selection()
- resources_subtract()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement