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 programmes for beginners. There are 366 days in a year, with an intercalary day on February 29th every four years.
public class Main
public static void main(String args)
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");
System.out.println("it is not a leap year");
it is not a leap year
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.
Compiler: Click Here