# 다이어트 실패 for문에 조건문이요 int i=1; i==months 이렇게는 안되는건가요? i=0 ; i < months 랑 횟수가 같은거 아닌가요? #### CODE <a class='btn btn-default' href='/codes/79820'>Link</a> ``` public class WeightAfterFiveMonths { public static void main (String[] args) { // 입력값 받기 double start = Double.parseDouble("72.4"); int after = Integer.parseInt("5"); // 계산 double result = weight(start, after); // 결과 출력 System.out.printf("%d개월 후 예상 몸무게 => %.2fkg", after, result); } // 시작 몸무게와 n개월 후 값을 입력받아 예상 몸무게를 반환 public static double weight(double currentWeight, int months) { double expectedWeight = currentWeight; for (int i=1; i==months; i++) { expectedWeight += 0.231; } return expectedWeight; } } ``` #### INPUT ``` ``` #### OUPUT ``` 5개월 후 예상 몸무게 => 72.40kg ```
## for문의 반복 조건 i = 0; i < months 와 횟수가 같으려면 아래를 참고 ``` for (int i = 1; i <= months; i++) { ... } ```