Payroll System with Abstract and Interface
hardQuestion 203Build 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, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
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.