编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习5
#include <iostream> using namespace std; const double N1=35000; const int N2=15000; const int N3=5000; int main() { double salary; double sui=0; cout<<"Enter the salary: "; while(cin>>salary && salary>=0) { if(salary<=N3) { sui=0; //cout<<"税收= "<<sui<<endl; } else if(salary>N3 && salary<=N2) { sui=(salary-N3)*0.10+N3*0; //cout<<"税收= "<<sui<<endl; } else if(salary>N2 && salary<=N1) { sui=(salary-N2)*0.15+(N2-N3)*0.10+N3*0; //cout<<"税收= "<<sui<<endl; } else { sui=(salary-N1)*0.20+(N1-N2)*0.15+(N2-N3)*0.10+N3*0; //cout<<"税收= "<<sui<<endl; } cout<<"sui= "<<sui<<endl; cout<<"Enter the salary: "; } system("pause"); return 0; }