Repository navigation
Expand file tree
/
Copy pathato-calc.py
More file actions
37 lines (32 loc) · 1.41 KB
/
Copy pathato-calc.py
File metadata and controls
37 lines (32 loc) · 1.41 KB
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
# Ask the user for their salary before tax
try:
salary = float(input("Enter your salary before tax: $"))
# Initialize tax variable
tax_paid = 0.0
# Calculate tax using if and nested if-else statements based on ATO brackets
if salary <= 18200:
# Bracket 1: $0 - $18,200 = Nil
tax_paid = 0.0
else:
# Nested if-else for income over $18,200
if salary <= 45000:
# Bracket 2: $18,201 - $45,000 = 16 cents for each $1 over $18,200
tax_paid = (salary - 18200) * 0.16
else:
if salary <= 135000:
# Bracket 3: $45,001 - $135,000 = $4,288 + 30 cents for each $1 over $45,000
tax_paid = 4288 + (salary - 45000) * 0.30
else:
# Income above the provided brackets
# Assuming the user stays within the provided logic scope:
print("Note: Salary exceeds the provided tax bracket table ($135,000).")
tax_paid = 4288 + (salary - 45000) * 0.30
# Calculate income after tax
income_after_tax = salary - tax_paid
# Display the results
print(f"\n--- Tax Calculation Summary ---")
print(f"Gross Salary: ${salary:,.2f}")
print(f"Personal Income Tax Paid: ${tax_paid:,.2f}")
print(f"Income After Tax: ${income_after_tax:,.2f}")
except ValueError:
print("Invalid input. Please enter a numeric value for the salary.")