A Year is called Leap Year which contains 366 days , which comes once every four years .
- A Leap year contains 366 days and occur in every 4 years.
- A century year (which is ending with 00 ) is a Leap year only if it is divisible by 400.
- A non century year is a leap year if it is divisible by 4 but not divisible by 100.
By using above rules , a year can be determined wheather it is a Leap year or not.
import java.io.*;
public class LeapYear{
public static void main(String args[]){
int year;
Scanner sc=new Scanner(System.in);
System.out.println(“Enter a Year”);
year=sc.nextInt();
if(((year%4==0)&& (year%100!=0))||(year%400==0)){
System.out.println(“The year is Leap Year”);
}
else{
System.out.println(“The year is not a Leap year”);
}
}
}
