Check for a leapyear in java.

Leap year is a year which comes once in a four year.

Java code for finding leap year are given below:

import java.util.Scanner;

public class leapyear {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);

System.out.print(“Enter the year=”);

int ly;
ly=s.nextInt();
if(ly%400==0)
System.out.println(“leapyear”);
else
if(ly%4!=0)
System.out.println(“Not leap year”);
else
if(ly%100!=0)
System.out.println(“leap”);

else
System.out.println(“not leap year”);
}
}

 

Output:-

 

Leave a Reply