CNSA-266-Personal/fivestar.py

38 lines
1.3 KiB
Python
Raw Normal View History

2024-04-23 09:40:13 -04:00
STD_TAX = 0.06
OTH_TAX = 0.05
while True:
con = "Z"
validstate = False
fullName = str(input("Enter your full name: "))
quan = int(input("Enter the number of items: "))
cost = float(input("Enter the cost per item: "))
discount = float(input("Enter the discount percentage (e.g. 10 for 10%): "))
state = str(input("Enter your state (e.g. PA): "))
if state == "PA":
tax = STD_TAX
validstate = True
elif len(state) != 2:
print("invalid state!")
validstate = False
else:
tax = OTH_TAX
validstate = True
# print("Welcome " + fullName + "!")
# print("You are purchasing " + str(quan) + " items at $" + str(cost) + " per item.")
# print("You will have " + str(int(discount)) + " percent discount.")
# print("Your total is $" + str(round(cost*quan - (((discount/100) * (cost*quan))))*(tax + 1)),2)
if validstate:
print("Thank you: " + fullName)
print("Your Order:")
print("\t Qualtity: " + str(quan))
print("\t Cost: $" + str(round((cost*quan-(cost*quan*(discount/100)))*(1+tax),2)))
while (con != "Y" and con != "y") and (con != "N" and con != "n"):
con = input("Do you want to start over? (Y/N): ")
if con == "N" or con == "n":
break