上传文件至 /
This commit is contained in:
27
LeapYear.java
Normal file
27
LeapYear.java
Normal file
@@ -0,0 +1,27 @@
|
||||
public class LeapYear {
|
||||
public static void main(String[] args) {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
System.out.print("请输入2000~3000内的年数!");
|
||||
int year = scan.nextInt();
|
||||
scan.close();
|
||||
|
||||
|
||||
if (year < 2000 || year > 3000) {
|
||||
System.out.println("请输入2000~3000内的年数!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
boolean isLeap = false;
|
||||
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
|
||||
isLeap = true;
|
||||
}
|
||||
|
||||
|
||||
if (isLeap) {
|
||||
System.out.println(year + "年是闰年");
|
||||
} else {
|
||||
System.out.println(year + "年不是闰年");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user