个人所得税问题
#include<stdio.h>
#define TAXBASE 3500
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,1e9,0.45}};
double CaculateTax(long profit)
{
int i;
double tax = 0.0;
profit -= TAXBASE;
for(i=0;i<sizeof(TaxTable)/sizeof(TAXTABLE);i++)
{
if(profit>TaxTable[i].start)
{
if(profit>TaxTable[i].end)
{
tax += (TaxTable[i].end-TaxTable[i].start)*TaxTable[i].taxrate;
} else{
tax += (profit-TaxTable[i].start)*TaxTable[i].taxrate;
printf("征税范围:%6ld~%6ld 该范围内缴税金额%6.2f\n",TaxTable[i].start,TaxTable[i].end,tax);
return tax;
}
printf("征税范围:%6ld~%6ld 该范围内缴税金额:%6.2f\n",TaxTable[i].start,TaxTable[i].end,tax);
}
}
return tax;
}
void main()
{
long profit;
double tax;
printf("请输入个人收入金额:");
scanf("%ld",&profit);
tax = CaculateTax(profit);
printf("您的个人所得税为:%f\n",tax);
}