Java program to check leap year

In this post, we will see how to check leap year.

import java.util.Scanner;

public class LeapYearFinder
{
    public static void main(String args[])
    {
       int year;
       Scanner scanner = new Scanner(System.in);

       System.out.print("Enter Year : ");
       year = scanner.nextInt();

       if((year%4 == 0) && (year%100!=0)){
           System.out.print(year+" is a Leap Year");
       }else if(year%100 == 0){
           System.out.print(year+" is not a Leap Year");
       }else if(year%400 == 0){
           System.out.print(year+" is a Leap Year");
       }else{
           System.out.print(year+" is not a Leap Year");
       }
    }
}

Output:

Enter Year : 2018
2018 is not a Leap Year

That’s all about Java program to check leap year.

[social_share share_on="facebook,twitter,linkedin,whatsapp"][post_navigator in_same_term="true"]

Leave a Reply

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

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.