当我尝试扫描输入收入的值时,我遇到了错误,这段代码有什么问题?我认为它与使用收入两次有关,我可以简单地改变变量的名称,是他们解决这个问题的另一种方法吗?
#include <stdio.h>
float TaxDue(float income){
float tax = 0;
if (income < 0){
printf("\nYou've Enter A Negative Income");
}
else if (income <= 750){
tax = (income * .01);
}
else if (income <= 2250){
tax = 7.50 + ((income - 750) * .02);
}
else if (income <= 3750){
tax = 37.50 + ((income - 2250) * .03);
}
else if (income <= 5250){
tax = 82.50 + ((income - 3750) * .04);
}
else if (income <= 7000){
tax = 142.50 + ((income - 5250) * .05);
}
else if (income > 7000){
tax = 230.00 + ((income - 7000) * .06);
}
else{
printf("\nError");
}
return tax;
}
int main(void){
float income = 0;
printf("Enter Your Taxable Income: ");
scanf("%f", income);
printf("\nYou Owe %f In Taxes", TaxDue(income));
return 0;
}
答案 0 :(得分:1)
在main中更改以下语句:
scanf("%f", income);
作为
scanf("%f", &income);