Answers for "Write a Java program that takes a year from the user and print whether that year is a leap year or not."

5

leap year program in java

public static boolean isLeapYear(int year) {
  if (year % 4 != 0) {
    return false;
  } else if (year % 400 == 0) {
    return true;
  } else if (year % 100 == 0) {
    return false;
  } else {
    return true;
  }
}
Posted by: Guest on June-30-2020
1

java leap year expression

(year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0))
Posted by: Guest on January-25-2021

Code answers related to "Write a Java program that takes a year from the user and print whether that year is a leap year or not."

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language