Create a Payable interface with a calculatePay() method. Implement this interface with Salaried and Contractor classes. Create a method that takes a List<Payable> and returns the total payroll amount.
Examples
Input: List<Payable> employees = [new Salaried(5000), new Contractor(50, 40)]
Output: 7000
Explanation: Salaried employee gets $5000, contractor gets $50 * 40 hours = $2000. Total is $7000.
Input: List<Payable> employees = [new Salaried(3000), new Salaried(4500), new Contractor(75, 20)]
Output: 9000
Explanation: First salaried gets $3000, second gets $4500, contractor gets $75 * 20 = $1500. Total is $9000.
Input: List<Payable> employees = [new Contractor(100, 10), new Contractor(60, 30)]
Output: 2800
Explanation: First contractor gets $100 * 10 = $1000, second gets $60 * 30 = $1800. Total is $2800.
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay July 2026
Contest runs July 1 - 31. Complete challenges to climb the leaderboard!
Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.