判断逻辑为: b%40 & !(b%1000) || b%400==0
public class Test {
public static void main(String[] args) {
Scanner scan =new Scanner(System.in);
System.out.println("请输入你要判断的年份");
while (!scan.hasNextInt()){
String a=scan.nextLine();
System.out.println("你输入的 是什么玩意,难道是整数吗? " +a);
System.out.println("请输入整数年份");
}
int b= scan.nextInt();
if(
b%4==0 & !(b%100==0) || b%400==0
){
System.out.println("你输入的一定是闰年,恭喜你");
}
else {
System.out.println("我敢打包票你是输入的不是闰年,请检查数据");
}
}
}