【发布时间】:2017-07-09 00:30:55
【问题描述】:
import java.util.Scanner;
public class LeapYearTester{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Please enter a year");
int year_input = input.nextInt();
// now make a Year object
Year theYear = new Year(year_input);
// now check to see if it's a leap year
if (theYear.isLeapYear())
System.out.println("That's a leap year!");
else
System.out.println("That's not a leap year!");
}
}
public class Year
{
// declare your instance variables here
private int theYear;
private int Year;
// write your constructor here
public Year(int y)
{
y=Year;
}
static boolean isLeapYear(final int Year) {
return Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0);
//(((Year%4==0) || (Year%400)) && ((!Year%100==0) || (Year%400=0)))
}
}
以上是主要的,不能更改。上课有问题。
【问题讨论】:
-
"上课有问题。"什么麻烦,哪个班?
-
你有我的同情。现在你的问题是什么?
-
为什么新手经常不看网站规则和要求就问,所有这些都可以在help center 部分轻松找到?原始发帖者,这个问题需要改进,包括努力描述你的代码、你的问题并提出一个具体的问题。
-
气垫船:为什么我们仍然想知道?
-
请注意,“我在使用 x 时遇到问题”并不是一个真正的问题 - 请参阅 Why is “Can someone help me?” not an actual question?。
标签: java class methods leap-year