判断闰平年 java

/*
* 闰平年判断条件:2个
* 1.能够被4整除 并且 不能被 100整除
* 2.能够被400整除
*/
import java.util.Scanner;
public class C6{
public static void main(String[] args) {
String desc = "闰年";
System.out.println("輸入年份");
int year = new Scanner(System.in).nextInt();
if((year %4 == 0 && year %100 !=0) || year %400 ==0){
System.out.println(year+"是"+desc);
}else {
desc = "平年";
System.out.println(year+"是"+desc);
}
}
}


---梁氏
posted @ 2020-10-09 19:03  Liang-shi  阅读(202)  评论(0编辑  收藏  举报