我试图让 LeapYear 方法返回它是否是 LeapYear(返回它实际上是什么 if 语句)。本质上,我是编码新手,我不知道如何返回字符串值而不是 int 或 double。有人可以帮我吗?
public static int LeapYear(int y) {
int theYear;
theYear = y;
if (theYear < 100) {
if (theYear > 40) {
theYear = theYear + 1900;
} else {
theYear = theYear + 2000;
}
}
if (theYear % 4 == 0) {
if (theYear % 100 != 0) {
System.out.println("IT IS A LEAP YEAR");
} else if (theYear % 400 == 0) {
System.out.println("IT IS A LEAP YEAR");
} else {
System.out.println("IT IS NOT A LEAP YEAR");
}
} else {
System.out.println("IT IS NOT A LEAP YEAR");
}
}