CJCoding With Joseph

Polymorphic Payroll

Build a payroll hierarchy from scratch. Define an abstract class Employee with an abstract method int WeeklyPay(). Then define two subclasses:
- HourlyEmployee(int rate, int hours) whose pay is rate * hours
- SalariedEmployee(int annualSalary) whose weekly pay is annualSalary / 52
The tester stores them in a List<Employee> and totals the weekly pay. Do NOT write a Main method.

For HourlyEmployee(20, 40) (pay 800) and SalariedEmployee(52000) (weekly 1000) the program prints:
1800

Expected Output:

1800
Topics:
Polymorphism
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.