#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

class Employee {
  private:
    string name;
    double salary;

  public:
    Employee(const string& name, double salary) : name(name), salary(salary) {};

    void setsalary(double salary) {
        this->salary = salary;
    }

    string getname() const {
        return name;
    }

    double getsalary() const {
        return salary;
    }
};
//自定义比较函数
bool compareSalaryDesc(const Employee& e1, const Employee& e2) {
    return e1.getsalary() > e2.getsalary();
}


// 个人所得税计算函数
double calculateTax(double salary) {
    const double threshold = 3500.0; // 起征点
    double taxableIncome = salary - threshold;
    double tax = 0.0;

    if (taxableIncome <= 0) {
        return 0.0;
    }

    if (taxableIncome <= 1500) {
        tax = taxableIncome * 0.03;
    } else if (taxableIncome <= 4500) {
        tax = taxableIncome * 0.1 - 105.0;
    } else if (taxableIncome <= 9000) {
        tax = taxableIncome * 0.2 - 555.0;
    } else if (taxableIncome <= 35000) {
        tax = taxableIncome * 0.25 - 1005.0;
    } else if (taxableIncome <= 55000) {
        tax = taxableIncome * 0.3 - 2755.0;
    } else if (taxableIncome <= 80000) {
        tax = taxableIncome * 0.35 - 5505.0;
    } else {
        tax = taxableIncome * 0.45 - 13505.0;
    }

    return tax;
}

int main() {
    // 创建 Employee 对象
    Employee e1("张三", 6500.0);
    Employee e2("李四", 8000.0);
    Employee e3("王五", 100000.0);

    // 存储 Employee 对象的容器
    vector<Employee> employees = {e1, e2, e3};

    // 使用 std::greater 进行降序排序
    sort(employees.begin(), employees.end(), compareSalaryDesc);
    cout <<fixed <<setprecision(1);
    // 输出结果
    for (const Employee& emp : employees) {
        double tax = calculateTax(emp.getsalary());
        cout << emp.getname() << "应该缴纳的个人所得税是:" << tax << endl;
    }

    return 0;
}