#C10300. Employee Salary Calculation and Sorting
Employee Salary Calculation and Sorting
Employee Salary Calculation and Sorting
You are given two tasks in this problem. The first task is to compute an employee's salary based on his/her hourly wage, hours worked, and an overtime policy. The overtime policy is defined as follows: if an employee works more than 40 hours, then any extra hour is paid at 1.5 times the hourly wage if overtime is allowed; otherwise, the extra hour is paid at the regular rate.
The second task is to sort a list of employees based on their total salaries (calculated with the same rule) in descending order. If two employees have the same salary, they should be sorted alphabetically by name.
Details:
- If the employee does not qualify for overtime (or does not have overtime allowed), the salary is simply hourly_wage * hours_worked.
- In case overtime applies and the hours worked are greater than 40, the salary is computed as: \(\text{salary} = \text{hourly_wage} \times 40 + (\text{hours_worked} - 40) \times \text{hourly_wage} \times 1.5\)
- All salary values must be rounded to two decimal places.
- For the sorting task, employees should be primarily sorted by descending total salary and then by ascending name order if there is a tie.
inputFormat
The input begins with a mode indicator:
- If the first integer is 1, perform the salary calculation for a single employee. In this case, the second line will contain three values separated by spaces:
hourly_wage
(a float),hours_worked
(a float) andovertime
(an integer, where 1 means True and 0 means False). - If the first integer is 2, perform the employee sorting task. The next integer
n
specifies the number of employees. Then,n
lines follow, and each line contains four fields separated by spaces:name
(a string),hourly_wage
(a float),hours_worked
(a float) andovertime
(an integer, 1 for True and 0 for False).
outputFormat
If the mode is 1, print the total salary rounded to two decimal places.
If the mode is 2, print the sorted employee names in one line separated by a space.
## sample1
15.00 40 0
600.00
</p>