//NAME: Danish Khan //STUDENT ID: 47324012 //NAME: Adam Su //STUDENT ID: 23628358 //This is the subclass for the Hourly Employee that extends our Employee class public class hourlyEmployee extends Employee { private int overtimeHour = 40; //number of hours before considered overtime private double overtimeRate = 1.5; //how many times original pay for overtime private int hourlyRate; //hourly wage private int grossPay; private int tax; // The constructor takes a name as a parameter and uses it to initialize // the employee's name. public hourlyEmployee(String name, int wage) //hourly employee constructor { super(name); //name hourlyRate = wage; //hourly rate is equal to whatever rate is inputed by the //user or in the input.txt } // createWeeklyPaycheck() creates and returns a weekly paycheck for this // employee, given the number of hours that were worked this week. public Paycheck createWeeklyPaycheck(int hoursWorked) { if (hoursWorked <= overtimeHour && hoursWorked >= 0) //case if hours worked is less than hours to qualify for overtime { grossPay = hourlyRate * hoursWorked; //gross = wage * total hours } else if (hoursWorked > overtimeHour) // case if hours qualifies for overtime { grossPay = hourlyRate * overtimeHour; //first 40 hours is calculated by wage * 40 grossPay = (int)(grossPay + ((hoursWorked - overtimeHour) * (overtimeRate*hourlyRate))); //total gross is calculated by the above + extra hours * overtime rate } else System.out.println("Invalid amout of hours inputed. Please change." + "Thank you"); tax = (int)(grossPay * 0.20); //tax is 20% of gross Paycheck p = new Paycheck((Employee)this, hoursWorked, grossPay, tax); //This returns the pay check for the hourly employee return p; } // toString() returns a String representation of this employee. Different // kinds of employees will have somewhat different String representations. public String toString() { return getName() +" (Hourly, " + CurrencyFormat.format(hourlyRate) + "/hr)"; } }