check entered year is leap year or not in java

Write a java program to check whether the entered year is leapyear or not.

import java.util.*;
public class leapyear 
{
     public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int yr;
        System.out.println("enter the year");
        yr=s.nextInt();
        if(yr%4==0)
        {
            if(yr%100==0)
            {
                if(yr%400==0)
                {
                    System.out.println("year is leap");
                }
                else
                {
                    System.out.println("year is not leap");
                }
            }
            else
            {
                 System.out.println("year is not leap");
            }
        }
        else
        {
            System.out.println("year is not leap");
     
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *