hey all iv have an assignment(wrtie an employee payroll program) which iv seen alot of other people have posted about so sorry for bringing it up again but im stuck. Iv made the program and it runs fine but it always calculates grosspay and netpay as 0.0 everything else (firstname etc shows up fine) shows up fine i cant figure out what isnt working properly. please help :)
below is the first part (EmployeePayroll.java) i can post the other part if you want me to(TestEmployeePayroll.java)
public class EmployeePayroll
{
private String firstName, lastName, id;
private double hoursWorked, payRate, grossPay, netPay, tax;
public EmployeePayroll()
{
firstName=""; lastName=""; id=""; hoursWorked=0; payRate=0;
tax = 0.42; //fixed tax rate(42%)
}//constructor
public EmployeePayroll(String firstName, String lasName, String id, double hoursWorked, double payRate)
{
this.firstName=firstName; this.lastName=lastName; this.id=id; this.hoursWorked=hoursWorked; this.payRate=payRate;
}//constructor
public void set(String firstName, String lastName, String id, double hoursWorked, double payRate, double grossPay, double netPay)
{
this.firstName=firstName; this.lastName=lastName; this.id=id; this.hoursWorked=hoursWorked; this.payRate=payRate; this.grossPay=grossPay; this.netPay=netPay;
}
public void calcGrossPay()
{
if (hoursWorked <= 38)
{
grossPay = hoursWorked*payRate;
}
else if (hoursWorked <= 42)
{
grossPay = 38* payRate + (hoursWorked - 38) * 1.5 * payRate;
}
else if (hoursWorked <= 60)
{
grossPay = 38 * payRate + 4 * 1.5 * payRate + (hoursWorked - 42) * 2 * payRate;
}
else
{
grossPay=hoursWorked*payRate;
}
}//end if
public void calcNetPay()
{
netPay=grossPay-(grossPay*tax);
}
public String GetFirstName()
{
return firstName;
}
public String GetLastName()
{
return lastName;
}
public double GetHoursWorked()
{
return hoursWorked;
}
public double GetHourlyPay()
{
return payRate;
}
public double GetGrossPay()
{
return grossPay;
}
public double GetNetPay()
{
return netPay;
}
public String GetId()
{
return id;
}
}