I've created 2 classes: Pay
and PaycheckCalculator
. Here is the method that does the computations:
public class Pay {
private double hoursWorked;
private double rateOfPay;
private double withRate;
private double grossPay;
private double netPay;
public Pay ()
{
withRate = 15;
rateOfPay = 5.85;
}
public void computeNetPay(double hours, double ratePay, double rateWith)
{
grossPay = hours * ratePay;
double newAmt = grossPay*rateWith/100;
netPay = grossPay - newAmt;
}
public void computeNetPay(double hours, double ratePay)
{
grossPay = hours * ratePay;
double newAmt = grossPay*withRate/100;
netPay = grossPay - newAmt;
}
public void computeNetPay(double hours)
{
grossPay = hours * rateOfPay;
double newAmt = grossPay*withRate/100;
netPay = grossPay - newAmt;
}
}
And here is the one that calls and displays the results, unfortunately, I cannot get it to run based on how the book requires it to run.
public class PayCheckCalculator {
public static void main(String[] args) {
Pay employee1 = new Pay(37.00, 12.00, 15.00);
Pay employee2 = new Pay (25.00, 11.00);
Pay employee3 = new Pay (15.00);
display(employee1);
display(employee2);
display(employee3);
}
public static void display (Pay paycheck)
{
System.out.println("Employee pay is" + Pay.computeNetPay);
}
}
Any tips will help me along in my re-education process.