-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram.py
74 lines (70 loc) · 1.7 KB
/
program.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import time as t
# Ask the user for the original price of the item
original_price = float(input("Enter the original price of the item: $"))
# Get the user's input for the state they are in
state = input("What state are you in? (Use the abbreviation, which \nyou can find in the file 'state_abbrev.txt') --> ")
# Define a dictionary to store the sales tax rates for each state
sales_tax_rates = {
'AL': 0.04,
'AK': 0.05,
'AZ': 0.0625,
'AR': 0.07,
'CA': 0.0825,
'CO': 0.03,
'CT': 0.0635,
'DE': 0.06,
'FL': 0.07,
'GA': 0.05,
'HI': 0.04,
'ID': 0.06,
'IL': 0.07,
'IN': 0.07,
'IA': 0.06,
'KS': 0.065,
'KY': 0.06,
'LA': 0.0975,
'ME': 0.055,
'MD': 0.06,
'MA': 0.0625,
'MI': 0.06,
'MN': 0.07,
'MS': 0.07,
'MO': 0.04225,
'MT': 0.06,
'NE': 0.055,
'NV': 0.0685,
'NH': 0.06,
'NJ': 0.07,
'NM': 0.07125,
'NY': 0.0845,
'NC': 0.07,
'ND': 0.05,
'OH': 0.0575,
'OK': 0.065,
'OR': 0.07,
'PA': 0.06,
'RI': 0.07,
'SC': 0.06,
'SD': 0.04,
'TN': 0.07,
'TX': 0.0625,
'UT': 0.06,
'VT': 0.06,
'VA': 0.053,
'WA': 0.065,
'WV': 0.06,
'WI': 0.05,
'WY': 0.04
}
state = state.upper()
# Use the user's input and the dictionary to calculate the sales tax rate
if state in sales_tax_rates:
sales_tax_rate = sales_tax_rates[state]
else:
print("Invalid state")
exit()
# Calculate the total cost with sales tax
total_cost = original_price * (1 + sales_tax_rate)
rounded_total = round(total_cost, 2)
print(f"The total cost with sales tax in {state} is ${total_cost}")
t.sleep(5) #When compiled to EXE, prevents the program from closing before printing the output.