📄 calcclass.cpp
字号:
#include "calcclass.h"
//个人所得税计算类实现部分
calc::calc()
{
}
calc::~calc()
{
}
double calc::calctax(bool judgement,double calcmoney)
{
double currenttax;
if (judgement==0) //判断是何种收入(0=pay,1=income)
currenttax=calcpay(calcmoney);
if (judgement==1)
currenttax=calcincome(calcmoney);
return currenttax;
}
double calc::calcpay(double moneytax) //CalcPay 计算工资,薪金所得税
{
double currenttax=0; //应缴税:currenttax
moneytax-=800;
if (moneytax<=0) //判断是否要缴税
currenttax=-1;
if (moneytax<=500)
currenttax=moneytax*0.05;
else if (moneytax<=2000)
currenttax=500*0.05+(moneytax-500)*0.1;
else if (moneytax<=5000)
currenttax=500*0.05+1500*0.1+(moneytax-2000)*0.15;
else if (moneytax<=20000)
currenttax=500*0.05+1500*0.1+3000*0.15+(moneytax-5000)*0.2;
else if (moneytax<=40000)
currenttax=500*0.05+1500*0.1+3000*0.15+15000*0.2+(moneytax-20000)*0.25;
else if (moneytax<=60000)
currenttax=500*0.05+1500*0.1+3000*0.15+15000*0.2+20000*0.25+(moneytax-40000)*0.3;
else if (moneytax<=80000)
currenttax=500*0.05+1500*0.1+3000*0.15+15000*0.2+20000*0.2+20000*0.35+(moneytax-60000)*0.35;
else if (moneytax<=100000)
currenttax=500*0.05+1500*0.1+3000*0.15+15000*0.2+20000*0.2+20000*0.25+20000*0.35+(moneytax-80000)*0.4;
else if (moneytax>=100000)
currenttax=500*0.05+1500*0.1+3000*0.15+15000*0.2+20000*0.2+20000*0.25+20000*0.35+20000*0.4+(moneytax-100000)*0.45;
if (currenttax<=0) //如果意外出错则为-2
currenttax=-2;
return currenttax;
}
double calc::calcincome(double moneytax) //CalcIncome 计算一次性劳动所得税
{
double currenttax; //应缴税:currenttax
if (moneytax<=0) //判断是否要缴税
currenttax=-1;
if (moneytax<=4000)
moneytax-=800;
else moneytax=moneytax-moneytax*0.2;
if (moneytax<=20000)
currenttax=moneytax*0.2;
else if (moneytax<=50000)
currenttax=20000*0.2+(moneytax-20000)*0.3;
else if (moneytax>=50000)
currenttax=20000*0.2+30000*0.3+(moneytax-50000)*0.4;
if (currenttax<=0) //如果意外出错则为-2
currenttax=-2;
return currenttax;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -