最近写了段计算个人所得税的算法,自己感觉比较不错。
public float ComputeTax(float income) //income为工资
{
float f_income=income-800; //起征基数为800,同时也可以参数化处理
float[] tax_line={0f,500f,2000f,5000f,20000f,40000f,60000f,80000f,100000f};//计算个人所得税的档次(假设员工为中国国籍,因为国籍不同起征点数不同,税率不同。)
float[] tax_rate={0f,0.05f,0.10f,0.15f,0.20f,0.25f,0.30f,0.35f,0.40f}; //各档次税率
float[] tax_sub={0.f,25f,125f,375f,1375f,3375f,6375f,10375f,15375f}; //采用了简化算法
int i_tax_level=0; //为了计算简便,把工资进行分档
while(f_income>tax_line[i_tax_level]&&i_tax_level<tax_line.length)
{
i_tax_level++;
};
if(i_tax_level>0)
{
float f_tax=tax_sub[i_tax_level-1]+(f_income-tax_line[i_tax_level-1])*tax_rate[i_tax_level]; //算税的公式
return f_tax;
}
else
{
return 0f;
}
}
本文地址:http://com.8s8s.com/it/it11816.htm