-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlabbb1.1.py
More file actions
51 lines (41 loc) · 1.37 KB
/
labbb1.1.py
File metadata and controls
51 lines (41 loc) · 1.37 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
# Ask user for input
name = input("Enter patient's name: ")
cleaning = input("Was cleaning performed? (y/n): ")
cavity_filling = input("Was cavity-filling performed? (y/n): ")
xray = input("Was X-Ray performed? (y/n): ")
# Constants
CLEANING_RATE = 60
CAVITY_FILLING_RATE = 200
XRAY_RATE = 100
TAX_RATE = 0.15
# Function to calculate the total bill
def calculate_bill(name, cleaning, cavity_filling, xray):
subtotal = 0
if cleaning == 'y':
subtotal += CLEANING_RATE
if cavity_filling == 'y':
subtotal += CAVITY_FILLING_RATE
if xray == 'y':
subtotal += XRAY_RATE
tax = subtotal * TAX_RATE
total_before_discount = subtotal + tax
# Apply discount if total bill is more than $200 or $300
if total_before_discount > 300:
discount_rate = 0.1
elif total_before_discount > 200:
discount_rate = 0.05
else:
discount_rate = 0
discount = subtotal * discount_rate
total = total_before_discount - discount
# Print the receipt
print("Melanie Dental Clinic")
print("------------------------")
print("Receipt for patient name:", name)
print("----------------------------")
print("Subtotal: $", subtotal)
print("Tax: $", tax)
print("----------------------------")
print("Total: $", round(total, 2))
# Calculate and print the bill
calculate_bill(name, cleaning, cavity_filling, xray)