#include
#define TAX_1 17850
#define TAX_2 23900
#define TAX_3 29750
#define TAX_4 14875
#define TAXRATE_1 0.15
#define TAXRATE_2 0.28
int main(void)
{
double taxsalary,taxpay;
int n;
printf("Please enter your taxsalary(q to quit):\n");
while(scanf("%ld",&taxsalary)==1)
{
printf("please enter your kinds of tax(from 1 to 4):\n");
printf("1)single tax: $17850 %15 more:%28\n");
printf("2)owner tax: $23900 %15 more:%28\n");
printf("3)double(together) tax: $29700 %15 more:%28\n");
printf("4)double(divorce) tax: $23900 %15 more:%28\n");
scanf("%d",&n);
if (n==1)
{
if(taxsalary<=TAX_1)
{
taxpay=taxsalary*TAXRATE_1;
printf("taxpay:%ld\n",taxpay);
}
else
{
taxpay=TAX_1*TAXRATE_1+(taxsalary-TAX_1)*TAXRATE_2;
printf("taxpay:%ld\n",taxpay);
}
}
if (n==2)
{
if (taxsalary<=TAX_2)
{
taxpay=taxsalary*TAXRATE_1;
printf("taxpay:%ld\n",taxpay);
}
else
{
taxpay=TAX_2*TAXRATE_1+(taxsalary-TAX_2)*TAXRATE_2;
printf("taxpay:%ld\n",taxpay);
}
}
if (n==3)
{
if (taxsalary<=TAX_3)
{
taxpay=taxsalary*TAXRATE_1;
printf("taxpay:%ld\n",taxpay);
}
else
{
taxpay=TAX_3*TAXRATE_1+(taxsalary-TAX_3)*TAXRATE_2;
printf("taxpay:%ld\n",taxpay);
}
}
if (n==4)
{
if (taxsalary<=TAX_4)
{
taxpay=taxsalary*TAXRATE_1;
printf("taxpay:%ld\n",taxpay);
}
else
{
taxpay=TAX_4*TAXRATE_1+(taxsalary-TAX_4)*TAXRATE_2;
printf("taxpay:%ld\n",taxpay);
}
}
printf("Please enter your taxsalary:(q to quit)\n");
}
return 0;
}
非常感謝,又仔細查了一下。是%lf,記錯了,