java小程序实例 闰年
判断闰年.
package com.test;
import java.util.Scanner;
import org.junit.Test;
public class TestRunNian {
@Test
public void test1() {
Scanner scanner = new Scanner(System.in);
while (true) {
int year = scanner.nextInt();
if (year == -1) {
System.out.println("程序结束!");
return;
}
if (year < 100 || year > 3000) {
System.out.println("年份输入有误");
} else {
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
System.out.println("输入的年份是闰年");
} else {
System.out.println("输入的不是闰年");
}
}
}
}
}
邮箱:wangh_2@sina.com