CJCoding With Joseph
15free / daySign inCreate account

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

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Abstract ClassesInterfacesClasses
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.