Given a year, return true if it is a leap year otherwise return false.
Please note that years that are multiples of 100 are not leap years, unless they are also multiples of 400.
Please note that years that are multiples of 100 are not leap years, unless they are also multiples of 400.
public class LeapYear {
static int test1 = 1983;
static int test2 = 2000;
static int test3 = 2100;
static int test4 = 2012;
static int testcase = test4;
public static void main(String args[]){
LeapYear
inst = new LeapYear();
boolean v = inst.isLeap(testcase);
System.out.println(v);
}
public boolean isLeap(int year){
if((year%4==0
&& year%100!=0 ) || (year%100==0 && year%400==0) )
return true;
else
return false;
}
}
No comments:
Post a Comment