10 - 判断某一年是否为闰年
Time Limit: 1000 Memory Limit: 65535
Submit: 585 Solved: 174
Description
编写一个类的方法,判断某一年是否为闰年。闰年的条件是符合下面二者之一:能被 4 整除,但不能被 100 整除;或者,能被400 整除。给定一个整数年份,能输出是否是瑞年,是则输出“Yes”,否则输出“No”。
Input
输入一个整数年份year
Output
输出是否是瑞年,是则输出“Yes”,否则输出“No”
Sample Input
1983
Sample Output
No
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
// TODO Auto-generated method stub
int year;
Scanner scanner = new Scanner(System.in);
year = scanner.nextInt();
if((year%4 == 0&&year%100!=0)||year%400==0)
System.out.println("Yes");
else
System.out.println("No");
}
}