// write your code here......
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;
class Employee {
private:
string name;
double salary;
// write your code here......
public:
Employee(string name,double salary)
{
this->name=name,this->salary=salary;
}
string getName()
{
return name;
}
double getSalary()
{
return salary;
}
};
bool cmp(Employee e1,Employee e2)
{
return e1.getSalary()>e2.getSalary();//按薪水从大到小排序
}
void print(Employee& e)
{
double tax=0.0;
double t=e.getSalary()-3500;
if(t>80000)
{
tax=t*0.45-13505;
}else if(t>55000)
{
tax=t*0.35-5505;
}else if(t>35000)
{
tax=t*0.3-2755;
}else if(t>9000)
{
tax=t*0.25-1005;
}else if(t>4500)
{
tax=t*0.20-555;
}else if(t>1500)
{
tax=t*0.1-105;
}else if(t>0)
{
tax=t*0.03;
}else{
tax=0.0;
}
cout<<fixed<<setprecision(1);
cout<<e.getName()<<"应该缴纳的个人所得税是:"<<tax<<endl;
}
int main() {
// write your code here......
Employee e1("张三",6500);
Employee e2("李四",8000);
Employee e3("王五",100000);
vector<Employee>v;
v.push_back(e1);
v.push_back(e2);
v.push_back(e3);
sort(v.begin(),v.end(),cmp);
for_each(v.begin(),v.end(),print);
return 0;
}