# 리뷰: 윤년 여부 계산 boolean result = false; 에서 true false 놓는 기준이 무엇인가여? #### CODE <a class='btn btn-default' href='/codes/77901'>Link</a> ``` public class LeapYear { public static void main(String[] args) { /* 1. 입력값 받기 */ int input = Integer.parseInt(args[0]); // "1988" => 1988 /* 2. 윤년 여부 계산 */ boolean output = isLeapYear(input); // 1988 => true /* 4. 결과 출력 */ System.out.printf("%d년은 윤년입니까? %s", input , output); } /* 3. 윤년 여부를 반환하는 메소드 */ public static boolean isLeapYear(int year) { // 변수 생성 boolean result = false; // 조건문 처리! (윤년 여부 판별!) if ((year % 4) == 0) { result = true; if ((year % 100) == 0) { result = false; if ((year % 1000) == 0) { result = true; } } } // 결과값 반환 return result; } } ``` #### INPUT ``` 1988 ``` #### OUPUT ``` 1988년은 윤년입니까? true ```
## boolean 타입의 지역변수는 보통 기본값을 false 로 놓습니다.