leap year program in java
Java
import java.util.Scanner;
public class LeapYear {
public static void main(String[] args){
int year;
System.out.println("Enter an Year :: ");
Scanner sc = new Scanner(System.in);
year = sc.nextInt();
if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))
System.out.println("Specified year is a leap year");
else
System.out.println("Specified year is not a leap year");
}
}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;
}
}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:
- Title
- how to fill a 2d array in java
- Category
- Java
- Title
- java nested loop
- Category
- Java
- Title
- java loop through arraylist
- Category
- Java
- Title
- hashmaps java
- Category
- Java
- Title
- how to count number of words in a string
- Category
- Java
- Title
- java method to capitalize first letter
- Category
- Java
- Title
- read integer input java
- Category
- Java
- Title
- treeset java descending order using comparator
- Category
- Java
- Title
- nullpointer extension
- Category
- Java
- Title
- D/NetworkSecurityConfig: No Network Security Config specified, using platform default
- Category
- Java
- Title
- java string to lower case
- Category
- Java
- Title
- java script find screen size of device
- Category
- Java
- Title
- how to print the map in java
- Category
- Java
- Title
- how to make a pre set list java
- Category
- Java
- Title
- center textview programmatically android
- Category
- Java
- Title
- how to delete an element from an array in java
- Category
- Java
- Title
- java string to uuid
- Category
- Java
- Title
- java for each loop
- Category
- Java
- Title
- remove spaces at beginning and end of string java
- Category
- Java
- Title
- java load image
- Category
- Java
- Title
- java letter alphabet index
- Category
- Java
- Title
- java decler variabel
- Category
- Java
- Title
- convert date to calendar java
- Category
- Java
- Title
- how to make an arraylist java
- Category
- Java
- Title
- absolute value java
- Category
- Java
- Title
- java execute jar from main
- Category
- Java
- Title
- java stack pop
- Category
- Java
- Title
- java stream collect to string
- Category
- Java
- Title
- java run project from command line
- Category
- Java
- Title
- contains example in java
- Category
- Java
- Title
- gravity in java
- Category
- Java
- Title
- how to get all the names of the files in a folder in java?
- Category
- Java
- Title
- how make a final variable in java
- Category
- Java
- Title
- kotlin jsonobject get nested
- Category
- Java
- Title
- hashmap get value java
- Category
- Java
- Title
- number of matches regex java
- Category
- Java
- Title
- enhanced for loop java
- Category
- Java
- Title
- ternary operator java
- Category
- Java
- Title
- junit meaning in java
- Category
- Java
- Title
- how to use pow function in java
- Category
- Java
- Title
- read csv java android
- Category
- Java
- Title
- replace regex group() java
- Category
- Java
- Title
- how to init an array with objects in java
- Category
- Java
- Title
- how to push an element in hashset java
- Category
- Java
- Title
- 2d array java
- Category
- Java
- Title
- java script to detect and launch all browsers
- Category
- Java
- Title
- take a value from keyboard java
- Category
- Java
- Title
- switch en java
- Category
- Java
- Title
- how to bubblesort a string array in java
- Category
- Java
- Title
- money value commas java
- Category
- Java
- Title
- gson parse json
- Category
- Java
- Title
- java 8 seconds to days
- Category
- Java
- Title
- remove unused imports intellij
- Category
- Java
- Title
- jq selector body
- Category
- Java
- Title
- how to return the lower of two values in one line java
- Category
- Java
- Title
- binary search java
- Category
- Java
- Title
- java for each
- Category
- Java
- Title
- select photo from camera android
- Category
- Java
- Title
- comparable on a generic class java
- Category
- Java
- Title
- springBoot
- Category
- Java
- Title
- java swing change label icon
- Category
- Java
- Title
- java how to make a string lowercase
- Category
- Java
- Title
- convert char to string java
- Category
- Java
- Title
- isSelfDivisor java
- Category
- Java
- Title
- byte java
- Category
- Java
- Title
- change fab image programatically
- Category
- Java
- Title
- android how to split string
- Category
- Java
- Title
- how to stop a void java
- Category
- Java
- Title
- processing sound android
- Category
- Java
- Title
- java how to show an array
- Category
- Java
- Title
- android studio centering textview in relativelayout
- Category
- Java
- Title
- substring java
- Category
- Java
- Title
- jtable get get row
- Category
- Java
- Title
- set top corner of shape radius programmatically android
- Category
- Java
- Title
- generate objects with for loop java
- Category
- Java
- Title
- date to string java
- Category
- Java
- Title
- java random integer
- Category
- Java
- Title
- get sha key android
- Category
- Java
- Title
- Java loop throug gson JsonElement
- Category
- Java
- Title
- java convert a char[] to string
- Category
- Java
- Title
- getcolor deprecated
- Category
- Java
- Title
- find first non repeating character in a string
- Category
- Java
- Title
- java vector push_back
- Category
- Java
- Title
- install java debian 8
- Category
- Java
- Title
- java create map
- Category
- Java
- Title
- linux change java
- Category
- Java
- Title
- bubble sort in java
- Category
- Java
- Title
- how to define an arraylist in java
- Category
- Java
- Title
- java instantiate collection with values
- Category
- Java
- Title
- math min max java
- Category
- Java
- Title
- java script num toSting syntax eror
- Category
- Java
- Title
- how to reverse a list in java
- Category
- Java
- Title
- java logical operator
- Category
- Java
- Title
- [ERROR] Error executing Maven. java.io.FileNotFoundException: The specified user settings file does not exist: /usr/lib/jvm/java-1.8.0-openjdk-amd64
- Category
- Java
- Title
- how to know if String is the same java
- Category
- Java
- Title
- How to make a class in Java?
- Category
- Java
- Title
- how to test for legit email in java
- Category
- Java
- Title
- take a peice from array java
- Category
- Java
- Title
- how to do for each in java
- Category
- Java
- Title
- load contents of file into string java
- Category
- Java