Last active
July 12, 2018 07:21
-
-
Save saminwankwo/38575dbb340b40aebf6db6f004982c82 to your computer and use it in GitHub Desktop.
code to determine whether the given year is leap year or not.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DetermineLeapYearExample { | |
public static void main(String[] args) { | |
//year we want to check | |
int year = 2004; | |
//if year is divisible by 4, it is a leap year | |
if((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))) | |
System.out.println("Year " + year + " is a leap year"); | |
else | |
System.out.println("Year " + year + " is not a leap year"); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment