Last active
August 29, 2015 14:14
-
-
Save JaHIY/3d945bdc62aff7a41174 to your computer and use it in GitHub Desktop.
Tax Calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env tclsh -- | |
proc tax_calculate {money} { | |
if {$money <= 3500} { | |
return 0 | |
} | |
set a [expr {$money - 3500}] | |
set tax_payment 0 | |
while true { | |
if {$a <= 1500} { | |
set tax_payment [expr {$tax_payment + $a*0.03}] | |
break | |
} elseif {$a <= 4500} { | |
set tax_payment [expr {$tax_payment + ($a - 1500)*0.1}] | |
set a 1500 | |
} elseif {$a <= 9000} { | |
set tax_payment [expr {$tax_payment + ($a - 4500)*0.2}] | |
set a 4500 | |
} elseif {$a <= 35000} { | |
set tax_payment [expr {$tax_payment + ($a - 9000)*0.25}] | |
set a 9000 | |
} elseif {$a <= 55000} { | |
set tax_payment [expr {$tax_payment + ($a - 35000)*0.3}] | |
set a 35000 | |
} elseif {$a <= 80000} { | |
set tax_payment [expr {$tax_payment + ($a - 55001)*0.35}] | |
set a 55000 | |
} else { | |
set tax_payment [expr {$tax_payment + ($a - 80000)*0.45}] | |
set a 80000 | |
} | |
} | |
return $tax_payment | |
} | |
if {$argc > 0} { | |
puts [tax_calculate [lindex $argv 0]] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment