<윤년의 조건>
윤년 : 2월 29일까지 있는 해
1. 년도가 400의 배수
2. 년도가 4의 배수이면서 100의 배수가 아닐때
3. 두 조건 중 하나의 조건이 충족되면 윤년
package test;
public class Test {
public static boolean isLeapYear(int year) {
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
return true;
} else {
return false;
}
}
public static void main(String[] args) {
int year = 2000; // 판별하고 싶은 연도 입력
if (isLeapYear(year)) {
System.out.println(year + "년은 윤년입니다.");
} else {
System.out.println(year + "년은 윤년이 아닙니다.");
}
}
}

