-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtip_calculator.py
More file actions
25 lines (15 loc) · 841 Bytes
/
tip_calculator.py
File metadata and controls
25 lines (15 loc) · 841 Bytes
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
#Tip calculator
# user enters the food charges
food_charges = float(input('Enter your charges '))
# calculate tip percentage
tip_percentage = 0.18
# calculate sales tax
sales_tax = 0.07
# calculate tip amount
tip_amount = float(food_charges * tip_percentage)
# calculate tax amount
tax_amount = float(food_charges * sales_tax)
# calculate grand total
grand_total = float(food_charges + tip_amount + tax_amount)
# print out tip amount, tax amount and grand total
print(f' tip = ${tip_amount:.2f}\n sales_tax = $ {tax_amount:.2f}\n grand_total = $ {grand_total:.2f}')