This was really hard to word since I'm not too sure what I should be asking but basically the task was to make a weekly pay calculator (ignoring taxes) that calculates overtime and regular pay
I have the following class
public class Hourly extends Employee {
private static double HourlyWage;
private static double Worked;
public Hourly(int Id, String Name, double HourlyWage, int Worked) {
super(Name, Id);
Hourly.HourlyWage = HourlyWage;
Hourly.Worked = Worked;
}
protected double WeeklyPay() {
if (Worked> 40) {
return (Worked - 40) * (HourlyWage * 1.5);
} else {
return HourlyWage * Worked;
}
}
@Override
public String toString() {
return "ID: " + Id + ", Name: " + Name + ", Hourly Wage: " + HourlyWage + ", Hours Worked: " + Worked;
}
and the following constructor
public static void main(String[] args) {
Hourly A = new Hourly (1111, "John Smith", 15.25, 40);
System.out.println(A);
Hourly B = new Hourly (2222, "Oliver Thomas", 15.50, 60);
System.out.println(B);
System.out.println("Weekly pay for Hourly worker: " + A.WeeklyPay());
System.out.println("Weekly pay for Hourly worker: " + B.WeeklyPay());
the output I get from this is:
ID: 1111, Name: John Smith, Hourly Wage: 15.25, Hours Worked: 40.0
ID: 2222, Name: Oliver Thomas, Hourly Wage: 15.5, Hours Worked: 60.0
and
Weekly pay for Hourly worker: 465.0
Weekly pay for Hourly worker #2: 465.0
Obviously, it doesn't consider the number of hours worked or the hourly pay how would I fix this?
If there is any further detail I need to provide let me know, thanks!