Java program to check whether the user input is leap year or not


Program
import java.util.Scanner; public class LeapYear { public static void main(String[] args) { int year; Scanner scan = new Scanner(System.in); System.out.println("Enter any Year:"); year = scan.nextInt(); scan.close(); boolean Leap = false; if(year % 4 == 0) { if( year % 100 == 0) { if ( year % 400 == 0) Leap = true; else Leap = false; } else Leap = true; } else { Leap = false; } if(Leap==true) System.out.println(year + " is a Leap Year."); else System.out.println(year + " is not a Leap Year."); } }
Input
Output

Similar Program

# Program Language
1 Java
2 Java
3 Java
4 Java
5 Java
6 Java
7 Java
8 Java
9 Java
10 Java
11 Java
12 Java
13 Java
14 Java
15 Java
16 Java
17 Java
18 Java
19 Java
20 Java
# Program Language