Private brackets(0 to 3,0 to 1) Private intervals(0 to 1,0 to 1) sub Init brackets(0,0) = 6000: brackets(0,1) = 0.17 brackets(1,0) = 25000: brackets(1,1) = 0.30 brackets(2,0) = 75000: brackets(2,1) = 0.42 brackets(3,0) = 150000: brackets(3,1) = 0.47 intervals(0,0) = 0: intervals(0,1) = 0.015 intervals(1,0) = 50000: intervals(1,1) = 0.025 end sub function IncomeTax(amount) Init() value = 0 lastRatio = 0 for c = 0 to 3 threshold = brackets(c,0) ratio = brackets(c,1) delta_ratio = ratio - last_ratio t = amount-threshold if t <= 0 then IncomeTax = value exit function end if value = value + (delta_ratio*t) last_ratio = ratio next IncomeTax = value end function function Medicare(amount) Medicare = amount * 0.015 if(amount >= 50000) then Medicare = amount * 0.025 end function function TaxedIncome(amount) TaxedIncome = amount-IncomeTax(amount)-Medicare(amount) end function function TaxedIncome_partyear(amount,ratio) TaxedIncome_partyear = TaxedIncome(amount/ratio)*ratio end function function min(a,b) if a ubound(brackets) then i = 1 else if intervals(ipos,0) < brackets(bpos,0) then i = 1 end if end if if i = 1 then x2 = intervals(ipos,0) newtax = intervals(ipos,1) ipos = ipos + 1 y = y + (x2-x)*(1-tax-med)-(newtax-med)*x2 x = x2 med = newtax else x2 = brackets(bpos,0) newtax = brackets(bpos,1) bpos = bpos + 1 y = y + (x2-x)*(1-tax-med) x = x2 tax = newtax end if loop end function function untaxed_partyear(taxed,ratio) untaxed_partyear = untaxed(taxed/ratio)*ratio end function