Skip to content

Instantly share code, notes, and snippets.

@saminwankwo
Last active July 12, 2018 07:21
Show Gist options
  • Save saminwankwo/38575dbb340b40aebf6db6f004982c82 to your computer and use it in GitHub Desktop.
Save saminwankwo/38575dbb340b40aebf6db6f004982c82 to your computer and use it in GitHub Desktop.
code to determine whether the given year is leap year or not.
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