判断是否为闰年

package course;

import java.util.Scanner;

public class LeapYear {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		System.out.println("请输入一个年份");
		long year = scan.nextLong();
		if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
			System.out.print(year + "年是闰年");
		} else {
			System.out.print(year + "年不是闰年");
		}
	}
}

posted on 2017-05-07 14:05  社会你锋哥  阅读(178)  评论(1编辑  收藏  举报

导航