Java Program to Check whether it's a Leap Year or Not
source link: https://www.geeksforgeeks.org/videos/java-program-to-check-whether-its-a-leap-year-or-not/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Java Program to Check whether it's a Leap Year or Not
- 450 Views
- 05/08/2022
In this video, we will write a JAVA Program to Check whether an year is a leap year or not.
Conditions for leap years:
1. A year must be divisible by 400 then it is a leap year.
2. If the year is divisible by 100 then it is not a leap year.
3. Else if the year is divisible by 4 then is a leap year.
4. If all conditions are false then enter year is not leap year.
Example:
Input year: 2024
Output: Yes
Input year: 2022
Output: No
We use Conditional operators to check leap years.
Here, the user is provided the flexibility to enter the year of own choice as Scanner Class is imported here rest of the if-else blocks are also combined in a single statement to check if the input year is a leap year.
Java Program to Find if a Given Year is a Leap Year: https://www.geeksforgeeks.org/java-program-to-find-if-a-given-year-is-a-leap-year/
Recommend
-
8
CPP Program to Check Whether a character is Vowel or ConsonantCPP Program to Check Whether a character is Vowel or ConsonantVideo Player is loading.Loaded: 0%Remaining Time -7...
-
5
C++ Program to Check whether a Number is Armstrong or notSkip to content
-
5
Java Program to Test whether a Number is Palindrome or notJava Program to Test whether a Number is Palindrome or not330 Views07/06/2022In...
-
4
C Program to Check Whether a Number is Prime or notC Program to Check Whether a Number is Prime or notHello friends. Welcome to weeks for Geeks. So
-
6
C++ Program to Check Whether Number is Even or OddSkip to content
-
4
Python Program to Check if a Year is Leap Year or notPython Program to Check if a Year is Leap Year or notHello everyone, welcome to Big Sur Geeks. I...
-
4
C Program to Check Leap YearSkip to content
-
4
C Program to Check Whether an Alphabet is Vowel or ConsonantSkip to content C Program...
-
5
Java program to Check whether the String contains only digitsSkip to content Java pr...
-
3
Java Program to Check Whether Number is Even or OddSkip to content
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK