Income tax Problem

You have been asked to write a program to calculate the income tax a person owes.   This is how that tax rate is figured.  Everyone pays 15% on the first $25,000 of earnings, they pay 25% on their second $25,000 of earnings and 28% on any earnings that is $75,000 and above.  If a person earns less than $25,000 and they have dependents, their tax rate is only 5%.   They want to see the earnings, each level of tax, and total tax.  

1.  Develop a problem statement:
    a.  Assumptions
    b.  Given
    c.  Calculations
    d.  Output

Problem statement

Problem statement:

Assumptions:

Only one person is calculated at at time.
Tax is only calculated based upon earnings and dependent status.
first level income = 25000
first level rate = .15
second level income 75000
second level rate = .25
above second level rate = .28
dependents under 25k rate = .05
 

Input:

1.  Earnings
2.  Dependents (yes/no)

Calculations:

1.  If earnings < first level income then
2         If dependents = "yes" then
3.             first level tax = earnings * dependents under 25k rate
        Else
4.              first level tax = earnings * first level rate
5.  Else
            first level tax = first level income * first level rate
            if earnings < second level income then
                 second level earnings = earnings - first level income
6.              second level tax = second level earnings * second level rate
7.  Else
            second level tax = 50000 * .25
8.          third level tax = (salary - 75,000) * .28
9.  total tax = first level tax + second level tax + third level tax
10.  Output:  Earnings
11.  Output:  first level tax
12.  Output:  second level tax 
13.  Output:  third level tax
14.  Output:  total tax

Human Algorithm

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Human Algorithm:

1.  Input Earnings
2.  If salary is less than $25,000 then
    Input: Dependents (yes/no)
3.  If earnings less than 25,000
4         If dependents = "yes"
5.             first level tax = earnings * .05
6.        Else first level tax = earnings * .15
7.  first level tax = 25,000 * .15
8.  Else
          firstleveltax = 25000 * .15       

if earnings are less than $75,000 then
9.         second level tax = (earnings - $25,000) * .25
10.  Else second level tax = 50000 * .25
11.          third level tax = (salary - 75,000) * .28
12.  total tax = first level tax + second level tax + third level tax
13.  Output:  Earnings
14.  Output:  first level tax
15.  Output:  second level tax 
16.  Output:  third level tax
17.  Output:  total tax

Flowchart

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Flowchart:

Code

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Code:

<script language="vbscript">
Dim earnings, dependents, firstleveltax, secondleveltax, thirdleveltax, totaltax

earnings = inputbox("What were your earnings?")

if earnings < 25000 then
    dependents = inputbox("Do you have any dependents? yes/no")
    if dependents = "yes" then
        firstleveltax = earnings * .05
    else
        firstleveltax = earnings * .15
    end if
Else
    firstleveltax = 25000 * .15
    if earnings < 75000 then
        secondleveltax = (earnings - 25000) * .25
    else
        secondleveltax = 50000 * .25
        thirdleveltax = (earnings - 75000) * .28
    end if
end if
totaltax = firstleveltax + secondleveltax + thirdleveltax

document.write "Earnings: " & formatcurrency(earnings)
document.write "<br>first level tax: " & formatcurrency(firstleveltax)
document.write "<br>second level tax: " & formatcurrency(secondleveltax)
document.write "<br>third level tax: " & formatcurrency(thirdleveltax)
document.write "<br>total tax: " & formatcurrency(totaltax)
</script>