I have to make a class called Payroll and a PayrollDemo class to go along with it.
This is my code so far for the Payroll Class:
public class Payroll {
private double hoursWorked, payRate;
public Payroll() {
hoursWorked = 0.0;
payRate = 0.0;
}
public void setHoursWorked(double hours) {
hoursWorked = hours;
}
public void setPayRate(double rate) {
payRate = rate;
}
public double getHoursWorked() {
return hoursWorked;
}
public double getPayRate() {
return payRate;
}
public String calcPay() {
if (hoursWorked <= 40) {
double grossPay = hoursWorked * payRate;
System.out.println("Regular Pay\n============\nHours: " + getHoursWorked() + "\nRate: $" + getPayRate() + "Gross Pay = $" + grossPay);
} else if (hoursWorked > 40) {
double grossPay = (40 * payRate) + ( (hoursWorked - 40) * payRate * 1.5 );
System.out.println("Pay With Overtime\n=================\nHours: " + getHoursWorked() + "\nRate: $" + getPayRate() + "Regular Pay = $" + (40 * payRate) + "\nOvertime Hours = " + (hoursWorked - 40) + "\nOvertime Pay Rate = $" + (payRate * 1.5) + "Overtime Pay = $" + ( (hoursWorked - 40) * payRate * 1.5 ) + "Gross Pay = $" + grossPay);
}
}
}
The problem is that I get an error: return statement missing. I tried replacing both Println with a return instead, but that did not work. So I was just wondering how to fix the program.
Aucun commentaire:
Enregistrer un commentaire