5000 tvarps:不收税
5001~15000 tvarps:10%
15001~35000 tvarps:15%
35000 tvarps以上:20%
例如,收入为38000 tvarps 时,所得税为5000*0.00+10000*0.10+20000*0.15+3000*0.20,即4600 tvarps。请编写一个程序,使用循环来要求用户输入收入,并报告所得税。当用户输入负数或非数字时,循环将结束。
#include <iostream>
using namespace std;
int main() {
double tvarps;
cout << "输入金额:";
while (cin >> tvarps){
if (tvarps > 0 && tvarps <= 5000) {
cout << "不收税\n";
}
else if (tvarps > 5000 && tvarps < 15000) {
tvarps = (tvarps - 5000) * 0.1;
cout << "收税:" << tvarps << endl;
}
else if (tvarps >= 15000 && tvarps < 35000) {
tvarps = 10000 * 0.1+(tvarps-15000)*0.15;
cout << "收税:" << tvarps << endl;
}
else if (tvarps >