PROGRAM FOR LEAP YEAR

The logic in this programe,if condition is x%4==0 means if we get remainder exactly equale to zero, then we can get the given year is leap year or not.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.util.Scanner;
public class LeapYear
{
    public static void main(String args[])
    {
          int x;
          System.out.println("Enter a year ");
          Scanner x = new Scanner(System.in);
          x = in.nextInt();
          if ( x %4 == 0 )
             System.out.println("Given year is leap year.");
          else
             System.out.println("Given year is not a leap year.");
     }
}

Output :Leap Year
gcdn