1

Java Program to Check whether it's a Leap Year or Not

 2 years ago
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.
neoserver,ios ssh client

Java Program to Check whether it's a Leap Year or Not

Java Program to Check whether it's a Leap Year or Not
Welcome to gigs for weeks. My name is
  • 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

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK