-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTipCalc.py
22 lines (20 loc) · 884 Bytes
/
TipCalc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
################################################
# TipCalc.py #
# Collects input about the user's bill #
# and returns the appropriate tip. #
# @auth: Brian Kittrell #
# @date: 10/20/2021 #
################################################
# Declarations/input
billTotal = 0.0
tipPercent = [0.15, 0.20]
userBill = input("Enter total bill amount: ")
# Main
try:
float(userBill)
except ValueError as error:
print("Must enter a decimal number like XX.XX without the dollar sign. Error: ", error, sep="")
else:
for item in tipPercent:
billTip = float(userBill) * item
print("$", round(billTip, 2), " is the ", (item * 100), "% tip on $", round(float(userBill), 2), ". Total with tip: $", round((billTip + float(userBill)), 2), sep="")