#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}};
double CaculateTax(long profit){
int i;
double tax = 0.0;
profit-=TAXBASE;
for(i=0;i<sizeof(taxTABLE)/sizeof(TAXBASE);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;
}
profit-=taxTABLE[i].end;
//printf("征税范围:%61d-%61d 该范围的缴纳税金额:%6.2f ",taxTABLE[i].start,taxTABLE[i].end,tax,(profit)>0?profit:0);
}
}
return tax;
}
void main(){
long profit;
double tax;
printf("请输入个人金额:");
scanf("%ld",&profit);
tax = CaculateTax(profit);
printf("您的个人所得税为:%12.2f
",tax);
}