Services
Tools
Entertainment
Study Material
About us
Covid-19
Home
/
Study Material
/ Java Programs
Study Materials
Check for Leap Year
JAVA
If Else and Switch Case
For and While Loops
Patterns and Series
String Manipulation
Arrays - 1D and 2D
Recursion
Stack, Queue and Linked List
String Buffer and String Tokenizer
Practical Questions
Miscellaneous
Write a program to enter a number as year and check if it is a leap year or not.
A leap year satisfies two conditions-
1. If the year is a multiple of 100, then it should be divisible by 400.
2. If the year is not a multiple of 100, then it is should be divisible by 4.
Some examples of leap year are - 2000, 2004, 1992
Some examples which are not leap year - 2100, 1997
class Leap_Year
{
public static void main(int n)
{
if(( n%400==0 ) || ( n%4==0 && n%100!=0 ))
System.out.println("YES");
else
System.out.println("NO");
}
}
Back
Next
Copyright © 2020 | All rights resereved