利用js计算月所得税以及年终奖所得税,并输出到网页
一:需求
根据以下规则,分别计算月个人所得税,年终奖所得税(年终奖为月工资3-20倍)。其中月工资为(2000,3500,7000,10000,15000,50000,80000,100000)
二:解决思路
利用JSON保存上述阶梯税表格,
以月工资数组为外循环去匹配相应阶级,生成年终奖;
并根据计算规则计算出所得税并输出
三:代码实现
function showTax(){
operation();
}
var table ={
free:3500,
taxtable:[
{low:-3500,high:0,rate:0,sub:0},
{low:0,high:1500,rate:0.03,sub:0},
{low:1500,high:4500,rate:0.1,sub:105},
{low:4500,high:9000,rate:0.2,sub:555},
{low:9000,high:35000,rate:0.25,sub:1005},
{low:35000,high:55000,rate:0.3,sub:2755},
{low:55000,high:80000,rat