Java Code
// Java program to check Leap Year
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a year: ");
int year = sc.nextInt();
// Leap year logic: divisible by 4, not 100 unless also 400
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
System.out.println(year + " is a Leap Year.");
} else {
System.out.println(year + " is not a Leap Year.");
}
}
}
Output
Enter a year: 2024
2024 is a Leap Year.