public class Hourly extends Employee { private String name; private double rate; public Hourly(String name, double rate) { super(name); this.rate = rate; } public double computePay(int hours) { if(hours <= 40) { return rate*hours; } return 40*rate + 3*rate*(hours - 40)/2; } @Override public String toString() { return String.format("%s earning %s per hour", getName(), rate); } }