个人所得税问题
问题描述
编写一个计算个人所得税的程序,要求输入金额后,能够输出应缴的个人所得税,个人所得税征收办法如下:
征起点为3500元。
不超过1500元的部分,征收3%。
超过1500~4500的部分,征收10%。
超过4500~9000的部分,征收20%。
超过9000~35000的部分,征收25%。
超过35000~55000的部分,征收30%。
超过55000~80000的部分,征收35%。
超过80000以上,征收45%。
程序设计
#include<iostream>
#define TAXBASE 3500
using namespace std;
typedef struct{
long start;
long end;
double taxrate;
}TAXTABLE;//定义结构体数组
TAXTABLE TaxTable[]={{0,1500,0.03},{1500,4500,0.10},{4500,9000,0.20},{9000,35000,0.25},{35000,55000,0.30},{55000,80000,0.35},{80000,90000,0.45}};
double CaculateTax(long profit)
{
int i;
double tax=0.0;
profit-=TAXBASE; //超过个人所得税起征点的收入
for(i=0;i<sizeof(TaxTable)/sizeof(TAXTABLE);i++)
{ //判断rofit是否在当前的缴税范围内
if(profit>TaxTable[i].start)
{
if(profit>TaxTable[i].end)//profit超过当前的缴税范围
{
tax+=(TaxTable[i].end-TaxTable[i].start)*
TaxTable[i].taxrate;
}
else //profit未超过当前缴费范围
{
tax+=(profit-TaxTable[i].start)*TaxTable[i].taxrate;
}
profit-=TaxTable[i].end;
cout<<"征税范围:"<<TaxTable[i].start<<"~"<<TaxTable[i].end<<"改范围内缴税金额:"<<tax<<"超出该范围的金额:"<<(profit)>0 ? profit:0;
}
}
return tax;
}
int main()
{ long profit;
double tax;
cout<<"请输入个人输入金额:"<<endl;
cin>>profit;
tax=CaculateTax(profit);
cout<<"您的个人所得税为:"<<tax;
}