public class Demo {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("请输入一个年份");
long year;
try {
year = scan.nextLong();
if(year%4==0&&year%10!=0||year%400==0){//是闰年
System.out.println(year+"是闰年!");
}else{
System.out.println(year+"不是闰年!");
}
} catch (Exception e) {
System.out.println("您输入的不是有效的年份");
}
}
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("请输入一个年份");
long year;
try {
year = scan.nextLong();
if(year%4==0&&year%10!=0||year%400==0){//是闰年
System.out.println(year+"是闰年!");
}else{
System.out.println(year+"不是闰年!");
}
} catch (Exception e) {
System.out.println("您输入的不是有效的年份");
}
}
}