CJCoding With Joseph
15free / daySign inCreate account

Payroll System

Build a payroll system with the following class hierarchy:

Payable (pure virtual base class): pay() and getRole() are pure virtual.

Staff (inherits from Payable): constructor Staff(string name) stores name as a public member.

FullTimeStaff (inherits from Staff):
- Constructor FullTimeStaff(string name, double monthlySalary)
- pay(): prints "Paying [name]: [salary]"
- getRole(): returns "Full-Time"

ContractStaff (inherits from Staff):
- Constructor ContractStaff(string name, double hourlyRate, int hours)
- pay(): prints "Paying [name]: [hourlyRate * hours]"
- getRole(): returns "Contract"

Do NOT write a main function.

Expected Output:

Paying Alice: 3000
Full-Time
Paying Bob: 1500
Contract

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

Hints4 available
Topics:
Abstract Classes
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.