Skip to content

Instantly share code, notes, and snippets.

@0ryant
Created August 1, 2019 10:07
Show Gist options
  • Save 0ryant/d624b8d0e68a3e1de0333a41bfd96bdc to your computer and use it in GitHub Desktop.
Save 0ryant/d624b8d0e68a3e1de0333a41bfd96bdc to your computer and use it in GitHub Desktop.
Java - Coding Challenge 4 - LeapYear
public class LeapYear {
public static boolean isLeapYear(int year) {
if (year < 1 || year > 9999) {
return false;
}
if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0) {
return true;
}
return false;
}
return true;
}
return false;
}
}
@ilialloyd
Copy link

ilialloyd commented Aug 30, 2022

public class LeapYear {
    public static boolean isLeapYear(int year){
        if(year<1 || year>9999){
            return false;
        }else{
            if(!(year%4==0)){
                return false;
            }else{
                if(!(year%100==0)){
                    return true;
                }else{
                    if(!(year%400==0)){
                        return false;
                    }
                    return true;
                }
            }
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment