Total the Pay of a Mixed Staff Array
easyQuestion 515Intern and Contractor both extend Worker and override weeklyPay(). Because each of them is a Worker, one Worker[] array can hold a mix of them, and calling weeklyPay() on an element runs the version that belongs to that object. Complete total in the Payroll class.
Requirements:
1. total(Worker[] staff) returns the sum of weeklyPay() for every element of staff.
2. An empty array gives 0.0.
3. Do not check which kind of worker each element is. One loop and one method call are enough.
The Worker, Intern and Contractor classes are provided. Do not change them. The tests also use a kind of worker that is not in this file.
Do NOT write a main method.
Expected output
1000.0= newline. The output ends with a newline, so print one after the last line.
Hints3 available
Sign in to use hintsTopics
InheritanceClasses
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.