-
Notifications
You must be signed in to change notification settings - Fork 0
/
main-3.py
22 lines (19 loc) · 888 Bytes
/
main-3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#If the bill was $150.00, split between 5 people, with 12% tip.
#Each person should pay (150.00 / 5) * 1.12 = 33.6
#Format the result to 2 decimal places = 33.60
#Tip: There are 2 ways to round a number. You might have to do some Googling to solve this.💪
#Write your code below this line 👇
print("Welcome to the tip calculator!")
bill = input("what was the total bill? $")
tip = input("how much you wanted to give tip? 10, 12, or 15? ")
people = input("how many people to split the bill? ")
bill_as_float = float(bill)
tip_as_int = int(tip)
people_as_int = int(people)
tip_as_percent = tip_as_int / 100
total_tip_amount = bill_as_float * tip_as_percent
total_bill = bill_as_float + total_tip_amount
bill_per_person = total_bill / people_as_int
final_amount = round(bill_per_person,2)
final_amount = "{:.2f}".format(bill_per_person)
print("each person should pay $",final_amount)