-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeginner - Conditionals debugging (practice code series)
More file actions
33 lines (28 loc) · 1.21 KB
/
Beginner - Conditionals debugging (practice code series)
File metadata and controls
33 lines (28 loc) · 1.21 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
main_dish = input().strip().lower()
time_of_day = int(input())
has_voucher = input().strip().lower() == 'true'
is_card_payment = input().strip().lower() == 'true'
# Check main dish and set cost accordingly
if main_dish == "paneer tikka":
cost = 250
elif main_dish == "butter chicken": # Corrected the typo in "butter chicken"
cost = 240
elif main_dish == "masala dosa": # Corrected the typo in "masala dosa"
cost = 200
else:
print("Invalid main dish") # Print error message for invalid dish
exit() # Exit the code if main dish is invalid
# Check time of day and calculate total cost
if time_of_day >= 12 and time_of_day <= 15: # Corrected the comparison operators
total_cost = (1 - 0.15) * cost # Apply 15% discount during lunch hours
else:
total_cost = cost # Otherwise, total cost remains the same
# Apply voucher discount if has_voucher is True
if has_voucher:
total_cost *= 0.9 # Apply 10% voucher discount (equivalent to 90% of total cost)
# Apply service charge for card payments
if is_card_payment:
service_charge = 0.05 * total_cost
total_cost += service_charge # Add service charge to total cost
# Print the total cost formatted to two decimal places
print(f"{total_cost:.2f}")