181.超过经理收入的员工

SQL架构

Employee 表包含所有员工,他们的经理也属于员工。每个员工都有一个 Id,此外还有一列对应员工的经理的 Id。

+----+-------+--------+-----------+
| Id | Name  | Salary | ManagerId |
+----+-------+--------+-----------+
| 1  | Joe   | 70000  | 3         |
| 2  | Henry | 80000  | 4         |
| 3  | Sam   | 60000  | NULL      |
| 4  | Max   | 90000  | NULL      |
+----+-------+--------+-----------+

给定 Employee 表,编写一个 SQL 查询,该查询可以获取收入超过他们经理的员工的姓名。在上面的表格中,Joe 是唯一一个收入超过他的经理的员工。

+----------+
| Employee |
+----------+
| Joe      |
+----------+

# Write your MySQL query statement below
SELECT E.Name Employee
    FROM Employee E ,Employee M
    WHERE E.ManagerId=M.Id AND E.Salary>M.Salary;

帮我写一段C++代码,要求如下:某软件公司员工(Employee)可以分为现有两类人员:行政管理人员(Manager)和项目开发人员(Developer)。现在需要对公司的人员信息进行统一管理,存储人员的编号(number)、姓名(name)、职务级别(position)、每月固定奖金(monthBonus)、每月月收入(monthIncome)和计算每月月收入(void calculateMonthIncome()),并且能够显示员工全部信息(void showInfo())。 行政管理人员和项目开发人员均划分成三个等级,行政管理人员分为总经理(级别为1)、部门经理(级别为2)和小组长(级别为3);行政管理人员月收入的计算公式为12000*(3-级别+1)/3+每月固定奖金,固定资金为3500元/月。 项目开发人员分为工作时间不满一年的(级别为3)、工作时间超过一年不到三年的(级别为2)和工龄在三年以上的(级别为1);项目开发人员月收入的计算公式为6000*(3-级别+1)/3+奖金,奖金为其加班的小时数*40元/小时+每月固定奖金500元。 试编程实现上述人员管理,用虚函数实现体现出多态性。将Employee类的声明放在employee.h文件中、Employee类的实现放在employee.cpp文件中;将Manager类的声明放在manager.h文件中、Manager类的实现放在manager.cpp文件中;将Developer类的声明放在developer.h文件中、Developer类的实现放在developer.cpp文件中;主函数放在main.cpp文件中。
最新发布
06-06
employee.h: ```cpp #ifndef EMPLOYEE_H #define EMPLOYEE_H #include <string> using namespace std; class Employee { protected: int number; string name; int position; double monthBonus; double monthIncome; public: Employee(int number, string name, int position, double monthBonus); virtual ~Employee(); virtual void calculateMonthIncome() = 0; void showInfo(); }; #endif ``` employee.cpp: ```cpp #include "employee.h" #include <iostream> using namespace std; Employee::Employee(int number, string name, int position, double monthBonus) { this->number = number; this->name = name; this->position = position; this->monthBonus = monthBonus; this->monthIncome = 0; } Employee::~Employee() {} void Employee::showInfo() { cout << "编号:" << number << endl; cout << "姓名:" << name << endl; cout << "职务级别:" << position << endl; cout << "每月固定奖金:" << monthBonus << endl; cout << "每月月收入:" << monthIncome << endl; } ``` manager.h: ```cpp #ifndef MANAGER_H #define MANAGER_H #include "employee.h" class Manager : public Employee { public: Manager(int number, string name, int position, double monthBonus); ~Manager(); virtual void calculateMonthIncome(); }; #endif ``` manager.cpp: ```cpp #include "manager.h" Manager::Manager(int number, string name, int position, double monthBonus) : Employee(number, name, position, monthBonus) {} Manager::~Manager() {} void Manager::calculateMonthIncome() { monthIncome = 12000 * (3 - position + 1) / 3 + monthBonus + 3500; } ``` developer.h: ```cpp #ifndef DEVELOPER_H #define DEVELOPER_H #include "employee.h" class Developer : public Employee { private: int workHours; public: Developer(int number, string name, int position, double monthBonus, int workHours); ~Developer(); virtual void calculateMonthIncome(); }; #endif ``` developer.cpp: ```cpp #include "developer.h" Developer::Developer(int number, string name, int position, double monthBonus, int workHours) : Employee(number, name, position, monthBonus) { this->workHours = workHours; } Developer::~Developer() {} void Developer::calculateMonthIncome() { if (position == 1) { monthIncome = 6000 * (3 - position + 1) / 3 + monthBonus + workHours * 40 + 500; } else if (position == 2) { monthIncome = 6000 * (3 - position + 1) / 3 + monthBonus + workHours * 40; } else { monthIncome = 6000 * (3 - position + 1) / 3 + monthBonus; } } ``` main.cpp: ```cpp #include "employee.h" #include "manager.h" #include "developer.h" #include <iostream> using namespace std; int main() { Employee *e1 = new Manager(1001, "张三", 1, 5000); Employee *e2 = new Manager(1002, "李四", 2, 3000); Employee *e3 = new Developer(2001, "王五", 3, 2000, 80); Employee *e4 = new Developer(2002, "赵六", 1, 1000, 120); e1->calculateMonthIncome(); e2->calculateMonthIncome(); e3->calculateMonthIncome(); e4->calculateMonthIncome(); e1->showInfo(); e2->showInfo(); e3->showInfo(); e4->showInfo(); delete e1; delete e2; delete e3; delete e4; return 0; } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值