判断是否为闰年
作者:互联网
import java.util.*;
class Main {
public static void main(String[] args){
//Create a Scanner
Scanner input = new Scanner(System.in);
System.out.print("Enter a year:");
int year = input.nextInt();
//Check if the year is a leap year
boolean isLeapYear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
//Display the result
System.out.print(year + " is a leap year? " + isLeapYear);
}
}
标签:判断,Scanner,闰年,是否,System,leap,year,print,out 来源: https://www.cnblogs.com/doudou-20123/p/16256874.html