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);
}
}
1 回答
![?](http://img1.sycdn.imooc.com/5911b5d10001c56212001200-100-100.jpg)
黄小凡
TA贡献69条经验 获得超36个赞
public class ControlStrcutureTest { public static boolean checkLeapYear(int a) { boolean is = false; if(a%4 == 0 && a%100 != 0 || a%400 == 0) is = true; return is; } public static void main(String[] args){ boolean isLeap = checkLeapYear(2000); System.out.println(isLeap); } }
你这写的也太乱了,而且单词也拼错了 ,true,不是ture
添加回答
举报
0/150
提交
取消