이유를 설명 할 수 있습니까? do-while 루프를 사용하면 항상 무한 루프가 발생합니다. 내가 뭘 놓치고 있니? 조건이 항상, 따라서 무한 루프를 충족되도록Java의 무한 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);
}
}
housrWorked가 변경되지 않았습니다. – Martin
왜 '무한하지 않아야합니까? – SLaks
이 게시물은 숙제로 표시되어야합니다 ;-) –