check leap year in java

Solutions on MaxInterview for check leap year in java by the best coders in the world

showing results for - "check leap year in java"
Juan Esteban
31 Feb 2019
1import java.util.Scanner;
2public class LeapYear {
3   public static void main(String[] args){
4      int year;
5      System.out.println("Enter an Year :: ");
6      Scanner sc = new Scanner(System.in);
7      year = sc.nextInt();
8
9      if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))
10         System.out.println("Specified year is a leap year");
11      else
12         System.out.println("Specified year is not a leap year");
13   }
14}
Arianna
31 Sep 2019
1public static boolean isLeapYear(int year) {
2  if (year % 4 != 0) {
3    return false;
4  } else if (year % 400 == 0) {
5    return true;
6  } else if (year % 100 == 0) {
7    return false;
8  } else {
9    return true;
10  }
11}
Leonardo
23 Apr 2016
1(year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0))
Lina
03 Feb 2018
1public class LeapYear {
2
3    public static void main(String[] args) {
4
5        int year = 1900;
6        boolean leap = false;
7
8        if(year % 4 == 0)
9        {
10            if( year % 100 == 0)
11            {
12                // year is divisible by 400, hence the year is a leap year
13                if ( year % 400 == 0)
14                    leap = true;
15                else
16                    leap = false;
17            }
18            else
19                leap = true;
20        }
21        else
22            leap = false;
23
24        if(leap)
25            System.out.println(year + " is a leap year.");
26        else
27            System.out.println(year + " is not a leap year.");
28    }
29}
Vincenzo
09 Sep 2017
1import java.util.Scanner;
2public class leapyear {
3    public static void main(String[] args)
4    {
5        Scanner myScanner = new Scanner(System.in);
6        System.out.println("Enter in the year ");
7        int year=myScanner.nextInt();
8
9        if(year%4==0)
10            if(year%100==0)
11                if(year%400==0)
12                    System.out.println("It is a leap year");
13                else
14                    System.out.println("it is not a leap year");
15            else System.out.println("It is a leap year");
16        else
17            System.out.println("Is not a leap year");
Noemi
05 Jun 2017
1import java.util.Scanner;
2public class LeapYearDemo
3{
4   public static void main(String[] args)
5   {
6      Scanner sc = new Scanner(System.in);
7      System.out.println("Please enter any year: ");
8      int year = sc.nextInt();
9      boolean temp = false;
10      if(year % 400 == 0)
11      {
12         temp = true;
13      }
14      else if(year % 100 == 0)
15      {
16         temp = false;
17      }
18      else if(year % 4 == 0)
19      {
20         temp = true;
21      }
22      else
23      {
24         temp = false;
25      }
26      if(temp)
27      {
28         System.out.println("Year " + year + " is a Leap Year");
29      }
30      else
31      {
32         System.out.println("Year " + year + " is not a Leap Year");
33      }
34      sc.close();
35   }
36}
queries leading to this page
leap year calculation javawrite a java program that takes a year from the user and print whether that year is a leap year or not given a year check if the year is leap year or not in javaleap year formula javawap to generate a year using random class and check whether it is leap or not using user defined packagehow to find a leap year in javaalgorithm of program to find that entered year is leap year or notleap year java methodjava leap year expressionfind if the year is leap year in javajava check if leap yearhow to check if leap year javaleap year write a method in javawrite a java program that takes a year from user and print whether that year is a leap year or notwhen does a leap year start javacheck if the year is a leap year or not in javajava program to check leap year 28nested if 29check the leap year for 4 5 6 7 in javaleap year java codefind if the year is leap or not in javajava code for leap year or notcheck leap year using time in javacheck to see if a number is a leapyear javaprogram to find leap year javajava lep yearcheck if year is leap year javaleap year if statementjava leapyear 28 29 methodleap year program in javajava function to get leap yearleap year checker javafinding leap year in javais leap year code javajava program to know if the year is a leap yearleap year java program randommathleapyear program in javaleap year logic in java to input 2020leap year checking in javaprogram to check leap year in javaprogram to find leap year in javaleap year in javaleap year condition in javawap to generate a year using random class and check whether it is leap or not using user defined package find leap year from date in javaleap year calculator javaleap year meaning in javaleap year if statement javahow to check for leap year in javais leap year javaleap year code javahow to account for leap years in java programjava program to check whether a given year is leap or notwhether a year is leap or not javaprogram to check leap yearleap year program injavajava program to find a leap year nothow to calculate if a year is a leap year javafind leap year in javajava program to check whether the given year is leap year or notleap year check using calander in java read year and check if the given year is a leap year javafind a leap year in javafunction year leap javawrite a program to check whether a given year is a leap year or not in javaleap year code in avajava code to check whether a year is a leap year or notleap in javahow to test if a year is a leap year javajava calendar know if year is leapwrite a java program to find whether a given year is leap year or not with variable table is leap javaleap year java programhow to do leap years in javahow to find wheter a year is leap year or not in javaleap year programming in javahow to check leap year in javawrite a program to check leap year in javaleapyear javajava test if it is leap yearprint the leap year javajava leap year programhow to check leap year javato check a leap year using random javawrite a java method to check whether an year 28integer 29 entered by the user is a leap year or not program to find leap year or not in javajava how to calculate leap yearleap year program in java test casesleap year calculation logic javawhat is a leap year javaleap year concept in javajava leapyearhow to check year is leap year or not in javahow to find leap year in javajava find if a year is leap or nothow to find if a year is a leap year in javaleapyear in javajava leap year calcultorcode of leap year in javaleap year logic in javahow to check whether the given year is leap or not in javahow to know if a year is a leap year javacondition for leap year in javawrite a java program that takes a year from user and print whether that year is a leap year or not finding leap year info in javacheck if a year is a leap year javajava if year is leapleap year or not in javajava program to find leap yearwrite a java program to check the leap yearis it a leap year in javahow to calculate leap year in javajava leap year check logicjava leap year calculatorleap year shortest program in javajava code leap yearjava method to calculate whether a leap year or notcheck leap year javajava check if year is leaphow to calculate a leap year in javaleap year program in java with explanationleap year conditions in javajava check for leap yearleap year program in java using methoda leap year java programjava leap yearshow to check whether the year is leap or not in javawrite a java program that takes a year from user and print whether that year is a leap year or not 5b4 5dcheck leap year in java stack overflowcheck for leap year in javacalculate leap year javacheck if the year is a leap year or not in java gfghow to check if leap year in javagiven the year input value 2c determine if that year was a leap year if a number is evenly divisible by 4 2c but not evenly divisible by 100 then it is a leap year coding in javahow to check if february and leap year javajava get leap yearprogram to calculate leap year in javaleap year function in javaleap year calculation in javagive the year and check if the leap year are not in javajava program to check leap yearwrite a program to input year from user and check whether the give0n year is leap year or not using if else javacode for leap year in javadeterminnig leap year in javajava program to check leap year or notif year is divisible by 4 in javacheck leap year in javasee if is a leap year javaleap year program in java javatpointjava check if year is leap methodprogram to determine leap year in javaleap year logic javaequation to find out leap year in javaleap year or not javaleap year java program for beginnerscheck if year is leap javajava program to find if given year is leap yearleap year jvaacheck if year is a leap year javahow to know a leap year javafind leap year or not in javawrite a java program that finds a given year is leap year or notjava program for leap yearjava code to check leap yearboolean leap year javawrite a java program to find if a year is leap year or not using for loopwrite a java program to find whether a given year is leap year or notjava check leap yearjava leap year methodfind out if an year is leap javajava code to find leap year or notleap year in java methodleap year requirements javaleap year program javacheck leap year or not in javajava code for leap yearleap year java best wayhow to count leap year on javahow to determine if a year is a leap year in javasymbol java statement this year is leap or notjava program to see if its leap year or notleap year java program input from keyboardhow to determine a leap year javahow to check if a given year is a leap year in java 3fcalculating lea year javaleap year calculation if statement javabest to detect leap year javawrite a java program to find whether a year entered by the user is a leap year or notleap year java program booleanwrite a java program to find whether the given year is leap year or not using conditionalwrite a program to find leap year in javaboolean leap year java with inputleap year code in javadays of months in a leap year program in javajava program to check whether a given year is leap or not using scannerjava program to leap yearhow to check if a year is a leap year javajava exception to find leap yearbest way to know if leap year javaleap year condition javajava leap yearjava write a program to check leap year 3f formula a year is a leap 2c if it is divisible by 4 and 400 but 2c not by 100 28if else statement 29write a program in java to check if its a leap yearis leap year method javaleap year javaleap year java loopjava method to find year is leap or notfind leap year javaleap year calendar javafollowing year is leap year javajava leap year questionjava is leap yearjava date get if year is leapleap year check in javaalgorithm for leap year javacheck leap year in java