-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay-15
83 lines (70 loc) · 2.12 KB
/
Day-15
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
83
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,
}
def report():
print(f"Water: {resources['water']}ml")
print(f"Milk: {resources['milk']}ml")
print(f"coffee: {resources['coffee']}gm")
def sufficent_resources(order):
ingredient = MENU[order]['ingredients']
for item in ingredient:
if resources[item] < ingredient[item]:
print("sorry, we don't have sufficient ingredients")
return False
return True
def coffee(order):
ingredient = MENU[order]['ingredients']
for item in ingredient:
resources[item] -= ingredient[item]
print(f"Here is your {order}☕, enjoy!")
def calculate_coins(order):
print("Please insert coin.")
quarters = int(input("How many quarters?: "))
dimes = int(input("How many dimes?: "))
nickles = int(input("How many nickles?: "))
pennies = int(input("How many pennies?: "))
given_money = quarters * 0.25 + dimes * 0.10 + nickles * 0.05 + pennies * 0.01
return given_money
def main_calculation():
while True:
order = input("What would you like? (espresso/latte/cappuccino/report): ").lower()
if order == "report":
report()
elif order in MENU:
if sufficent_resources(order):
coffee_price = MENU[order]["cost"]
process = calculate_coins(order)
if process > coffee_price:
left_amount = process - coffee_price
print(f"Here is your change {left_amount:.2f}")
coffee(order)
else:
print(f"Sorry, amount is not sufficient. Money refunded{process}")
main_calculation()