Java Program to check if year is a LEAP year or Not | Java Tutorials for Beginners

preview_player
Показать описание
Support Simple Snippets by Donations -
--------------------------------------------------------------------------------------------- In this java programming tutorial we will write a program to check if a year is LEAP year or not.

Concept of Leap Year -
The rule states:
“Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400.”

For example,
if year = 2400, it is leap year,(Condition 1 satisfied)
but if year = 2200, is NOT a leap year, (Cond. 2 not satisfied),
and if year = 2020, is a leap year, (Cond. 2 satisfied).

To check whether a year is a leap year or not, you need to check the following 3 conditions:
IF
1. Any year that is divisible by 400 is definitely a leap year.
ELSE IF
2. If divisible by 4 AND not divisible by 100 then a leap year.
ELSE
not a leap year.

Simple Snippets Official Website -
Simple Snippets on Facebook-
Simple Snippets on Instagram-
Simple Snippets Google Plus Page-
Simple Snippets email ID-
Рекомендации по теме
Комментарии
Автор

Hey Guys, if you want more such tech educational videos on this channel then please support me by subscribing to this channel & also share it with your friends as it helps me create more content just for you ✌

SimpleSnippets
Автор

Ur explanation is too gud, thank you soo much...😊

keerthykalipogu
Автор

what if i want to print that february 29 on a particular year is invalid, do u know how?

BWVidventures
Автор

Your explanation is really awesome...I will tell all my friends to subscribe. Thank you so much. School teachers don't explain properly and then we have problems. But you really solved my problem. 💕

shadanabashir
Автор

how about if its not a leap the output is that it indicates the next leap year like 1702 not a leap year so it outputs that the next leap is 1704

lloydbenablo
Автор

Sir your video is awesome, but sir l am a new beginner of Java, so sir l want you to make a video of Java beginners to learn Java for the first time... Thanks a lot sir. I am sure that you understand my problem.

tausifalamsanfui
Автор

leap yearing is a confusing program. if you did something wrong somewhere the code would be faulty even without you knowing it

fzmbrhz
Автор

Scanner scan = new Scanner(System.in);
System.out.println("Enter any Year:");
year = scanner.nextInt(); for scanner
we could use boolean, too right? i am just 13 n yet we aren't allowed anything except menu driven n scanner is a must lol...

gaurid
Автор

Here is a shorter version
int year =1800;

System.out.println(true);
else {

System.out.println(true);
else
System.out.println(false);
}

mevlutkaymaz
Автор

2020 is a leap year but it cannot be divided by 400 to get 0. Can you explain?

afanboy
Автор

Can you plz do a program on switch case ?

shadanabashir
Автор

Can u plz tell me that whether both the conditions have to be true or anyone of them would be enough???? Plz reply fast!!

shadanabashir
Автор

IF (year%400==0)
Can you explain why did we use ==0
And what does it mean

vishalchavda
Автор

" I am not get going to details about astrology"
😅😅😅

narpathrajpurohit