Leap year or not program in java using if-else

Write a leap year or not program in java using if-else. This software, written in the Java programming language, will show whether the year is a leap year or not. This bundle contains a set of basic Java programs for beginners. There are 366 days in a year, with an intercalary day on February 29th every four years. 

import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
int year;
System.out.println("Enter the year");
Scanner sc = new Scanner(System.in);
year = sc.nextInt();
if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))
System.out.println("it is a leap year");
else
System.out.println("it is not a leap year");
}
}

 

Output:
3000                                                                                                                                                     
it is not a leap year 

Reason behind the leap year

Because a planet’s orbit around the Sun (year) and spin on its axis (day) are not precisely aligned, leap years occur.

Almost every other planet in our solar system is the same way. On Mars, for example, leap years outnumber normal years!

Why leap year is calculated for every fours in february

The leap day is a day that comes every four years and is known as February 29. Because the Earth does not circle the sun in exactly 365 days, this day is added to the calendar in leap years as a correction measure. 

The Julian calendar, which was initially used by the Romans, was modified into the Gregorian calendar.

What is leap year and how to check the year is leap year

A year of 366 days and an intercalary day on February 29th that occurs every four years. 2020 is a leap year, with 366 days.

Every four years, we add an additional day to our calendars, February 29. It’s a leap year if the number is divisible by four.

If-else statement in java program

The conditional statements in Java are as follows: If a particular condition is true, use if to specify a block of code to be run. 

If the same condition is false, use otherwise to define a block of code to run. If the initial condition is false, use else if to provide a new condition to test.

Leap year or not program in java using if-else

According to the proleptic calendar system guidelines, the isLeap() method of the Year class in Java is used to determine if this Year object is a leap year or not. If a year has 366 days, it is considered a leap year. A year is a leap year if it is divisible by four, according to the principles of the proleptic calendar system.