java

Java Program to find leap year or not

Here is a simple Java program for beginners,

Write a Java program to find a leap year or not.

Formula for finding a Leap year is as follows:

1. A year should be evenly divisible by 4 (should not have a reminder):

    year % 4 == 0 ( reminder should be 0 )

2. AND Year should not be evenly divisible by 100 (should have a reminder):

    year % 100 != 0 ( reminder should not be 0 )

3. OR Year should be evenly divisible by 400 (should have a reminder):

    year%400 == 0 ( reminder should be 0 )

So basically 1 && 2 || 3

if (1  and 2) both are true or 3 is true then it is a leap year

 

Here is the Java program to find the leap year,



Hope this post will be helpful for Java Beginners.

Related Posts

Leave a Reply