![](/img/trans.png)
[英]I can't seem to figure out how to get this print out all the words including the duplicates
[英]I can't figure out how to get the third method to print out in the fourth method
第三種方法應該確定年份是否為a年,而第四種方法應該通過字符串將信息打印出來? 但是我不知道怎么辦? 編輯后*仍然給我一個錯誤。 不知道為什么
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"");
}
}
}
用與將getYear()的結果存儲到變量中並將該值作為參數傳遞給isLeap的方法相同,您需要對isLeap的結果進行相同的操作並將該值作為參數傳遞給displayResults
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.