-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtip_calculator.py
27 lines (19 loc) · 996 Bytes
/
tip_calculator.py
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
# Initial welcome message to the tip calculator
print ("Welcome to the tip calculator.")
# Gets the total bill from the user
total_bill = input("What was the total bill? ")
# Takes the $ sign off so we can convert it to a floating point
total_bill_int = float(total_bill[1:])
# Gets the tip percentage
tip = input("What percentage tip would you like to give? 10, 12, or 15? ")
# Converts the tip to a 0. value for calculation
tip_edit = '0.' + tip
tip_percentage = float(tip_edit)
# Gets the total bill for future calclation
bill_total = (total_bill_int * tip_percentage) + total_bill_int
# Asks the user to input the total number of people to split the bill
total_people = int(input("How many people to split the bill? "))
# Calculates the total per person and rounds to 2 decimal places since it's a money value
total_per_person = round(bill_total / total_people, 2)
# Final statement to add the $ back to the print statement
print(f"Each person should pay: ${total_per_person}")