← Back to Classes
Question 203
Payroll System with Abstract and Interface
Payroll System with Abstract and Interface
Build a small payroll system. 1. Create an interfacePayablewith a methoddouble pay(). 2. Create an abstract classStaffthat implementsPayable. It has aprotected String namefield and a constructor. It does NOT implementpay()— subclasses must. 3. CreateFullTimeStaffextendingStaff. Constructor takesnameanddouble monthlySalary.pay()returnsmonthlySalary. 4. CreateContractStaffextendingStaff. Constructor takesname,double hourlyRate, andint hours.pay()returnshourlyRate * 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
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.