#include <iostream>
const float class1=5000;
const float class2=10000;
const float class3=20000;
const float tax1=0;
const float tax2=0.1;
const float tax3=0.15;
const float tax4=0.2;
int main() {
using namespace std;
float tax;
float income;
cout<<"Enter your income:";
while(cin>>income&&income>=0)
{
if(income<=class1)
tax=income*tax1;
else if(income<=class2)
tax=(income-class1)*tax2;
else if(income<=class3)
tax=class2*tax2+(income-class2-class1)*tax3;
else
tax=class2*tax2+class3*tax3+(income-class3-class2-class1)*tax4;
cout<<"Your tax owed is: "<<tax<<" tvarps."<<endl;
cout<<"Next case,enter your income:";
}
return 0;
}
C++ primer plus 6th 第六章6.5编程题参考答案
最新推荐文章于 2024-11-09 13:08:09 发布