-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay 15 - Coffee Machine Program
More file actions
82 lines (72 loc) · 2.72 KB
/
Day 15 - Coffee Machine Program
File metadata and controls
82 lines (72 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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,
}
continue_ordering = True
while continue_ordering:
usr_ipt = input("What would you like? (espresso/latte/cappuccino): ").lower()
coffee_input = ['espresso', 'latte', 'cappuccino']
# print(MENU[f"{usr_ipt}"]["cost"])
total_amount = 0.0
milk_left = 0.1
if usr_ipt == coffee_input[0] or usr_ipt == coffee_input[1] or usr_ipt == coffee_input[2]:
water_left = resources["water"] - MENU[f"{usr_ipt}"]["ingredients"]["water"]
if usr_ipt != coffee_input[0]:
milk_left = resources["milk"] - MENU[f"{usr_ipt}"]["ingredients"]["milk"]
coffee_left = resources["coffee"] - MENU[f"{usr_ipt}"]["ingredients"]["coffee"]
if water_left > 0 and milk_left > 0 and coffee_left > 0:
print("Please insert coins.")
quarters = float(input("how many quarters?: "))
dimes = float(input("how many dimes?: "))
nickles = float(input("how many nickles?: "))
pennies = float(input("how many pennies?: "))
total_amount = ((quarters * 25) + (dimes * 10) + (nickles * 5) + (pennies * 1)) / 100
change_amount = total_amount - MENU[f"{usr_ipt}"]["cost"]
if total_amount < MENU[f"{usr_ipt}"]["cost"]:
print("Sorry that's not enough money. Money refunded.")
else:
print(f"Here is ${change_amount} in change.")
print(f"Here is your {usr_ipt} ☕️. Enjoy")
resources["water"] -= MENU[f"{usr_ipt}"]["ingredients"]["water"]
if usr_ipt != coffee_input[0]:
resources["milk"] -= MENU[f"{usr_ipt}"]["ingredients"]["milk"]
resources["coffee"] -= MENU[f"{usr_ipt}"]["ingredients"]["coffee"]
elif water_left < 0:
print(f"Sorry there is not enough water")
elif milk_left < 0:
print(f"Sorry there is not enough milk")
elif coffee_left < 0:
print(f"Sorry there is not enough coffee")
elif usr_ipt == 'report':
print(f"Water: {resources['water']}ml")
print(f"Milk: {resources['milk']}ml")
print(f"Coffee: {resources['coffee']}g")
print(f"Money: ${total_amount}")
else:
continue_ordering = False