/**
* 给定一个年份,判断是否是闰年
* @author littleRich
* A:能被4整除,并且不能被100整除。或者
* B:能被400整除。
*/
public class LeapYear {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Please input a year:");
int y = scan.nextInt();
if(y % 4 == 0 && y % 100 != 0 || y % 400 == 0){
System.out.println(y + " is a leap year!");
}else {
System.out.println(y + " isn't a leap year!");
}
scan.close();
}
}
给定一个年份,判断是否是闰年
最新推荐文章于 2021-01-13 13:46:15 发布