**已关闭。**此问题为not reproducible or was caused by typos。目前不接受答案。
这个问题是由一个打字错误或一个无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
3天前关闭。
Improve this question
我正在编写一个C计算器,它会输出你买卖股票后的净利润。我希望它考虑到资本利得税,所以我想一个if语句会比较合适。我的if语句有问题,计算器不能正确工作。谢谢!
#include <stdio.h>
#include <stdlib.h>
int main()
{
float sharebuyprice;
float sharesellprice;
int shares;
float profit;
float income;
printf("\nHow many shares did you buy?");
scanf("%d", &shares);
printf("\nWhat was the price per share?");
scanf("%f", &sharebuyprice);
printf("\nWhat price did you sell them for?");
scanf("%f", &sharesellprice);
printf("\nWhat is your annual income before taxes?");
scanf("%f", &income);
profit = (shares * sharesellprice) - (shares * sharebuyprice);
income = profit + income;
if(income >= 0 && income <= 0 41675) {
printf("Your profit is: %f", profit);
}
else if(income >= 41676 && income < 0 459751) {
profit = profit - (income * 0.15);
printf("Your profit is: %f", profit);
}
else{
profit = profit - (income * 0.25);
printf("Your profit is: %f", profit);
}
return 0;
}
我试过操纵我的if语句来纠正这个问题,但是我所做的一切都不起作用。
1条答案
按热度按时间ctzwtxfj1#
也许这对你有用...我所做的只是删除了一些语法错误...