5 50 5hb ib b b 5b readfile

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: rker karen = new HourlyWorker(“Karen Price”, 13.75, 40); staff[0] = john; staff[1] = sue; staff[2] = karen; for (int i=0; i<3; i++) { staff[i].calculateEarnings(); staff[i].print(); } } } Ans: public abstract class Employee { private String employeeName; public abstract double calculateEarnings(); } public class Boss extends Employee{ private double weeklySalary; public double calculateEarnings() { return weeklySalary; } }   public class CommissionWorker extends Employee { private double salary; private double commission; private int quantity; public double calculateEarnings() { return salary + commission*quantity; } } public class HourlyWorker extends Employee { private double wage; // wage per hour private double hours; // hours worked for week public double calculateEarnings() { return wage * ho...
View Full Document

This document was uploaded on 03/11/2014.

Ask a homework question - tutors are online