double m_tax(double salary,int month)
{
int count_salary = salary - month * 5000;
int tax = 0;
if( count_salary > 0)
{
if(count_salary<36000)
{
return count_salary * 0.03;
}
else if( count_salary>36000 && count_salary < 144000)
{
return 36000 * 0.03 + (count_salary - 36000)*0.1;
}
else if( count_salary > 144000 && count_salary < 300000)
{
return 36000 * 0.03 + (144000 - 36000)*0.1 + count_salary - 144000 * 0.2;
}
else if( count_salary > 300000 && count_salary < 420000)
{
return 36000 * 0.03 + (144000 - 36000)*0.1 + (300000 - 144000) * 0.2 + (count_salary - 300000) * 0.25;
}
else if( count_salary > 420000 && count_salary < 660000)
{
return 36000 * 0.03 + (144000 - 36000)*0.1 + (300000 - 144000) * 0.2 + (420000 - 300000) * 0.25 + (count_salary - 420000) * 0.3;
}
else if( count_salary > 660000 && count_salary < 960000)
{
return 36000 * 0.03 + (144000 - 36000)*0.1 + (300000 - 144000) * 0.2 + (420000 - 300000) * 0.25 + (660000 - 420000) * 0.3 + (count_salary - 660000) * 0.35;
}
else if( count_salary > 960000)
{
return 36000 * 0.03 + (144000 - 36000)*0.1 + (300000 - 144000) * 0.2 + (420000 - 300000) * 0.25 + (660000 - 420000) * 0.3 + (960000 - 660000) * 0.35 + (count_salary - 960000) * 0.45;
}
}
else
{
return 0;
}
}
int main()
{
double money,tax,sum=0;
int i;
for(i=1;i<=12;i++)
{
scanf("%lf",&money);
sum+=money;
tax=m_tax(sum,i);//这里需要传sum
printf("the sum of %d months tax is %.2f\n",i,tax);
}
return 0;
}