-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (22 loc) · 1.12 KB
/
main.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
28
29
30
31
32
33
34
#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 = int(input("What was the total bill? Php"))
# tip = int(input("What percentage would you like to give? 10, 12, or 15? "))
# split_bill = int(input("How many people to split the bill? "))
# bill_per_person = (bill / split_bill) * ((tip / 100) + 1)
# print(f"Each person should pay: Php{int(bill_per_person)}")
#Angela YU solution
print("Welcome to the tip calculator!")
bill = float(input("What was the total bill? $"))
tip = int(input("What percentage would you like to give? 10, 12, or 15? "))
people = int(input("How many people to split the bill? "))
tip_as_percent = tip / 100
total_tip_amount = bill * tip_as_percent
total_bill = bill + total_tip_amount
bill_per_person = total_bill / people
final_amount = round(bill_per_person, 2)
print(f"Each person should pay: ${final_amount}")