HW2_Q2

 avatar
user_7676782
python
2 years ago
730 B
1
Indexable
Never
FIRST_TAX_RATE = 0.1
SECOND_TAX_RATE = 0.14
THIRD_TAX_RATE = 0.21
FOURTH_TAX_RATE = 0.31


# this func is calc the tax for the user salary
def calc_tax(num):
    if num > 13860:
        taxRate = num * FOURTH_TAX_RATE
        return taxRate
    elif 13860 > num > 8921:
        taxRate = THIRD_TAX_RATE * 8921 + FOURTH_TAX_RATE * (num - 8921)
        return taxRate
    elif 8920 > num > 5221:
        taxRate = SECOND_TAX_RATE * 5221 + THIRD_TAX_RATE * (num - 5221)
        return taxRate
    else:
        taxRate = num * FIRST_TAX_RATE
        return taxRate


def main():
    salary = int(input("enter your salary"))
    taxRate = calc_tax(salary)
    print(f"The tax is: {taxRate:.2f}")


main()