Question: Can someone fix this loop inside the calculatePay method from the Company,java sample? Company.java Sample: public void calculatePay() { for (int i = 0; i
Can someone fix this loop inside the calculatePay method from the Company,java sample?
Company.java Sample:
public void calculatePay() {
for (int i = 0; i < noEmployees; i++) {
getEmployee(i).calculatePay();
}
}
I need it to loop over all employees calling calculatePay on each employee. Calculate pay is a method in my Employe class:
Employee.java sample:
public void calculatePay() {
totalHoursWorked = 0;
grossPay = 0;
fedTax = 0;
stateTax = 0;
netPay = 0;
totalTax = 0;
for (int i = 0; i < getNoTimeCards(); i++) {
TimeCard timeCard = getTimeCard(i);
totalHoursWorked += timeCard.getHoursWorked();
}
grossPay = totalHoursWorked * payRate;
if (grossPay >= 200) {
fedTax = (grossPay - 200) * .1;
} else {
fedTax = 0;
}
stateTax = grossPay * .04;
totalTax = fedTax + stateTax;
netPay = grossPay - totalTax;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
