有人可以解释为什么吗?当我使用 do-while 循环时,我总是遇到无限循环。我错过了什么?
package com.assignment2;
public class FooCorporation {
public static void main(String[] args) {
employee(9.50, 55);
employee(8.20, 47);
employee(10.00, 73);
}
public static void employee(double basePay, int hoursWorked) {
double salary = 0;
int overtimeHours = 40;
do {
if (basePay >= 8.00 || hoursWorked > 40 ) {
if (hoursWorked > 40) {
salary = basePay * hoursWorked
* ((hoursWorked - overtimeHours) * 1.5);
} else {
salary = basePay * hoursWorked;
}
}
else
System.out.println("According to law: Base Pay should be more than $8.00");
System.out.printf("Total Pay: %d %.2f\n", hoursWorked, salary);
} while (hoursWorked <= 60);
}
}