📜  闰年或不使用 if-else 在 Java 中编程 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:36.711000             🧑  作者: Mango

代码示例1
import java.util.Scanner;public class Main{public static void main(String[] args){int year;System.out.println("Enter the year");Scanner sc = new Scanner(System.in);year = sc.nextInt();if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))System.out.println("it is a leap year");elseSystem.out.println("it is not a leap year");}}