leap year checker java
public class LeapYear {
public static void main(String[] args) {
int year = 1900;
boolean leap = false;
if(year % 4 == 0)
{
if( year % 100 == 0)
{
// year is divisible by 400, hence the year is a leap year
if ( year % 400 == 0)
leap = true;
else
leap = false;
}
else
leap = true;
}
else
leap = false;
if(leap)
System.out.println(year + " is a leap year.");
else
System.out.println(year + " is not a leap year.");
}
}
Also in Java:
- import collections in java
- convert hashset to int array java
- bukkit java get player count
- java how to initialize an array
- creating a program about user asked to enter a number and enters 0 to stop, then calculates the sum of numbers entered, the average, the length of positive numbers and negative numbers entered by the user in java
- loop through java object
- how lock horizontal orientation android
- java loop
- system.in example in java
- get file path java
- parsedouble java
- find the triplet sum in java linked list
- count word in string no matter the delimiter java
- how to declare a linked list in java
- how to check if a string is in alphabetical order in java
- java next permutation
- java get an int from a char
- make a commet in java
- how to detect device javascirpt
- java add a list to a list
- how to replace all of one character with nothing in java
- Error executing Maven. java.io.FileNotFoundException: The specified user settings file does not exist: /etc/java-8-openjdk
- inheritance in java
- print arraylist java