...

/

Personal Income Tax Calculator

Personal Income Tax Calculator

Learn about branching and logical operators, and use them for calculating income tax.

Problem

Here, we have the Australian personal income tax rates for some financial years:

Taxable income

Tax on this income

0–$18,200

Nil

$18,201–$37,000

19c for each $1 over $18,200

$37,001–$80,000

$3,572 plus 32.5c for each $1 over $37,000

$80,001–$180,000

$19,822 plus 37c for each $1 over $80,000

$180,001 and over

$54,232 plus 45c for each $1 over $180,000

Note: An Australlian dollar has 100 cents. An expression such as 19c means 19 cents.

Write a program to calculate how much tax an Australian needs to pay based on the above information.

  • Assume that the annual salary is available to your program in a variable annual_income of type String.

  • The program should store the calculated tax in the income_tax variable.

annual_income = 80000 # For annual income of $80000
income_tax = 17547.0 # The payable tax is $17547
Tax calculated from annual income

Purpose

  • Use of if ...