package work; //编写ControlStrcutureTest类,为该类增加一个函数checkLeapYear, //函数参数为整数年份,返回值为true/false,该函数用于判断某年份是否闰年 //,在main函数中,分别用 220, 618, 960, 1271, 1368, 1644, 1912, 1949, 2000, //2017, 2020等年份进行测试。闰年判断规则如下: //①能被4整除且不能被100整除的为闰年。 //②能被400整除的是闰年。 public class ControlStrcutureTest { public static boolean checkLeapYear(int a) { boolean is = false; if(a%4 == 0 && a%100 != 0 || a%400 == 0) is = ture; else ; return is; } public static void main(String[] args){ System.out.println("hello world"); ControlStrcutureTest ok = new ControlStructureTest(); checkLeapYear(100); System.out.println(is); } }
黄小凡
相关分类