根據下面提到的平板計算雇員向政府支付的所得稅:
Income slab Tax
2.5L-5.0L 5%
5.0L-10.0L 20%
Above 10.0L 30%
這里 2.5L 表示 250,000
#include <stdio.h>
int main()
{
float tax = 0, income;
printf("Enter your annual income\n");
scanf("%f", &income);
if (income >= 250000 && income <= 500000)
{
tax = tax 0.05 * (income - 250000);
}
if (income >= 500000 && income <= 100000)
{
tax = tax 0.20 * (income - 50000);
}
if (income > 100000)
{
tax = tax 0.30 * (income - 100000);
}
printf("Tax to be paid by you is Rs%f\n", tax);
return 0;
}
uj5u.com熱心網友回復:
看起來你少了幾個零。線
income >= 500000 && income <= 100000
值不可能大于等于 500,000 且小于 100,000。
你是說 1,000,000 嗎?還是五萬?
嘗試這個:
#include <stdio.h>
int main()
{
float tax = 0, income;
printf("Enter your annual income\n");
scanf("%f", &income);
if (income >= 250000 && income <= 500000)
{
tax = tax 0.05 * (income - 250000);
}
/// Changed "100000" to "1000000" in the following sections
if (income >= 500000 && income <= 1000000)
{
tax = tax 0.20 * (income - 50000);
}
if (income > 1000000)
{
tax = tax 0.30 * (income - 1000000);
}
printf("Tax to be paid by you is Rs%f\n", tax);
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/373386.html
標籤:C
下一篇:c中的鏈表回傳負數而不是添加節點
