CJCoding With Joseph
15per day

Payroll System with Abstract and Interface

Build a small payroll system.

1. Create an interface Payable with a method double pay().
2. Create an abstract class Staff that implements Payable. It has a protected String name field and a constructor. It does NOT implement pay() — subclasses must.
3. Create FullTimeStaff extending Staff. Constructor takes name and double monthlySalary. pay() returns monthlySalary.
4. Create ContractStaff extending Staff. Constructor takes name, double hourlyRate, and int hours. pay() returns hourlyRate * hours.

Do NOT write a main method.

Expected Output:

Alice: 5000.00
Bob: 3200.00
Topics:
Abstract ClassesInterfacesClasses
Code Editor
1
Tab to indent · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.