问题:
解答:
#include <iostream>
using namespace std;int main()
{float salary = 0;float tax = 0;while (salary>=0){cout << "请输入您的工资:";cin >> salary;if (cin.fail())break;if (salary <= 5000){tax = 0;}else if (salary <= 15000){tax = (salary-5000) * 0.1;}else if (salary <= 35000){tax = (salary - 15000) * 0.15 + 10000 * 0.1;}else if (salary > 35000){tax = (salary - 35000) * 0.2 + 20000 * 0.15 + 10000 * 0.1;}cout << salary << "元的税收为:" << tax << endl;}cout << "Bye!" << endl;return 0;
}
运行结果:
考查点:
- 循环
- 条件
2024年8月28日20:11:46