Here you will get java program for leap year.
Condition for Leap Year
A year completely divisible by 400 is leap year.
A year completely divisible by 4 but not divisible by 100 is leap year.
For example: 2000, 2008, etc are leap year while 1900, 1997, etc are not leap year.
Java Leap Year Program
import java.util.Scanner; public class JavaLeapYear { public static void main(String...s){ int year; Scanner sc = new Scanner(System.in); System.out.println("Enter a year (Ex: 1990):"); year = sc.nextInt(); if((year%400 == 0) || (year%100 != 0 && year%4 == 0)){ System.out.println("leap year"); } else{ System.out.println("not leap year"); } } }
Output
Enter a year (Ex: 1990):
1996
leap year
Enter a year (Ex: 1990):
1900
not leap year