java:判断闰年与平年
import java.util.Scanner;
/* 闰年:能整除4且不能整除100
能整除400
*/
public class YearDemo{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
System.out.println("请输入你想要查询的年份:");
int year = s.nextInt();
if(year%4 == 0){
if(year%100 == 0){
if(year%400 == 0){
System.out.println(year+"是闰年");
}
else{
System.out.println(year+"是平年");
}
}
else{
System.out.println(year+"是闰年");
}
}
else{
System.out.println(year+"是平年");
}
}
}
能整除400
*/
public class YearDemo{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
System.out.println("请输入你想要查询的年份:");
int year = s.nextInt();
if(year%4 == 0){
if(year%100 == 0){
if(year%400 == 0){
System.out.println(year+"是闰年");
}
else{
System.out.println(year+"是平年");
}
}
else{
System.out.println(year+"是闰年");
}
}
else{
System.out.println(year+"是平年");
}
}
}