#include
using namespace std;
int main()
{
do
{
double income, tax;
cout << "enter the income:";
if (!(cin >> income) || income < 0)
{
cout << "请输入正数数字!";
cin.clear();
continue;
}
else if (income<=5000)
{
tax = 0;
}
else if (income<=15000)
{
tax = (income - 5000 )* 0.1;
}
else if (income <= 35000)
{
tax = (income - 15000)* 0.15+1000;
}
else
{
tax = (income - 35000)* 0.2 + 4000;
}
cout << tax<<endl;
} while (true);
cin.get();
cin.get();
return 0;
}
输入数字的话会没有事,可以循环下去。但是输入字母,就不会管下一次的cin,一直循环,不知道为什么