Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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;
  }
}
Comment

java leap year expression

(year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0))
Comment

java leap year

  public static void main(String[] args) {
        int year = 2005;

        if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))){
            System.out.println(year+" leap year");
        }else {
            System.out.println(year+" not a leap year");
        }
    }
Comment

java check if year is leap

      boolean isLeap =  new GregorianCalendar().isLeapYear(2020);
      //returns true
Comment

Leap year or not program in java using if-else

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");elseSystem.out.println("it is not a leap year");}}
Comment

PREVIOUS NEXT
Code Example
Java :: java 8 function supplier consumer 
Java :: java 8 stream add to list 
Java :: what is java steam 
Java :: devotional meaning 
Java :: button height is not increase in android studio 
Java :: $950 at 6% per annum for three years. 
Java :: jgit clone in memory 
Java :: how to get history stack in android webview 
Java :: how to make character in jframe 
Sql :: mysql disable safe mode 
Sql :: mysql reset auto increment value 
Sql :: postgresql stop all connections 
Sql :: mysql get table size 
Sql :: running query in redshift 
Sql :: turn on foreign keys check mysql 
Sql :: print in pl sql 
Sql :: finding duplicate column values in table with sql 
Sql :: dbms output 
Sql :: find largest table in mysql database 
Sql :: oracle list constraints 
Sql :: postgresql truncate cascade restart identity 
Sql :: ubuntu stop mysql 
Sql :: mysql 1 day ago 
Sql :: psql get sequences 
Sql :: mysql concatenate two columns into one 
Sql :: rename table postgres 
Sql :: sql select table header 
Sql :: Create a keyspace cassandra 
Sql :: create table if not exists postgresql 
Sql :: alter sequence set current value oracle 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =