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!

Create an Account

Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.

Create account

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 Feb 2026

Contest runs February 1 - 28. Complete challenges to climb the leaderboard!

Points are calculated for challenges completed during the contest period.