1import java.util.Scanner;
2public class LeapYear {
3 public static void main(String[] args){
4 int year;
5 System.out.println("Enter an Year :: ");
6 Scanner sc = new Scanner(System.in);
7 year = sc.nextInt();
8
9 if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))
10 System.out.println("Specified year is a leap year");
11 else
12 System.out.println("Specified year is not a leap year");
13 }
14}
1public static boolean isLeapYear(int year) {
2 if (year % 4 != 0) {
3 return false;
4 } else if (year % 400 == 0) {
5 return true;
6 } else if (year % 100 == 0) {
7 return false;
8 } else {
9 return true;
10 }
11}
1public static boolean isLeapYear(int year) {
2 if (year % 4 != 0) {
3 return false;
4 } else if (year % 100 != 0) {
5 return true;
6 } else if (year % 400 != 0) {
7 return false;
8 } else {
9 return true;
10 }
11}
1public class LeapYear {
2
3 public static void main(String[] args) {
4
5 int year = 1900;
6 boolean leap = false;
7
8 if(year % 4 == 0)
9 {
10 if( year % 100 == 0)
11 {
12 // year is divisible by 400, hence the year is a leap year
13 if ( year % 400 == 0)
14 leap = true;
15 else
16 leap = false;
17 }
18 else
19 leap = true;
20 }
21 else
22 leap = false;
23
24 if(leap)
25 System.out.println(year + " is a leap year.");
26 else
27 System.out.println(year + " is not a leap year.");
28 }
29}
1import java.util.Scanner;
2public class leapyear {
3 public static void main(String[] args)
4 {
5 Scanner myScanner = new Scanner(System.in);
6 System.out.println("Enter in the year ");
7 int year=myScanner.nextInt();
8
9 if(year%4==0)
10 if(year%100==0)
11 if(year%400==0)
12 System.out.println("It is a leap year");
13 else
14 System.out.println("it is not a leap year");
15 else System.out.println("It is a leap year");
16 else
17 System.out.println("Is not a leap year");