The Third Method is supposed to figure out if the year is a leap year or not and the fourth is supposed to print the info out through a string? But I don't know how? AFTER EDIT* Still giving me an errors. Don't know why
第三种方法应该判断年份是否是闰年,第四种方法应该通过字符串打印信息?但我不知道怎么办?编辑后*仍然给我一个错误。不知道为什么
import java.util.Scanner;
public class LeapYear {
public static void main(String[] args) {
displayInstructions();
int year = getYear();
isLeap(year);
}
public static void displayInstructions() {
System.out.println("This program asks you to enter a year as a 4 digit number. The output will indicate whether the year you entered is a leap year.");
}
public static int getYear() {
Scanner reader = new Scanner(System.in);
System.out.println("Enter a year: ");
int year = reader.nextInt();
return year;
}
public static boolean isLeap(boolean year) {
if (year % 4 == 0 && year % 100) {
isleap = true;
}
else {
return false;
}
}
public static void displayResuls(isLeap year) {
if (isLeap)
{
System.out.println("Year" +year+" is a Leap Year.");
}
else {
System.out.println("Year" +year+ "is not a Leap Year"");
}
}
}
1 个解决方案
#1
0
In the same way you store the result from getYear() into a variable and pass that value as a parameter to isLeap you need to do the same with the result from isLeap and pass that value as a parameter to displayResults
以同样的方式将结果从getYear()存储到变量中并将该值作为参数传递给isLeap,您需要对isLeap的结果执行相同的操作,并将该值作为参数传递给displayResults
#1
0
In the same way you store the result from getYear() into a variable and pass that value as a parameter to isLeap you need to do the same with the result from isLeap and pass that value as a parameter to displayResults
以同样的方式将结果从getYear()存储到变量中并将该值作为参数传递给isLeap,您需要对isLeap的结果执行相同的操作,并将该值作为参数传递给displayResults