润年案例
package test;
import java.util.Scanner;
public class runnian {=
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.print("请输入年份:");
Scanner s = new Scanner(System.in);
int n = s.nextInt();
//润年判断:能被4整除但不能被100整除的年份,或者能被400整除的年份1900
if(((n%4==0)&&(n%100!=0))||(n%400==0)){
System.out.println(n+"是润年");
}
else{
System.out.println(n+"不是润年");
}
}
}
运行结果:
请输入年份:1900
1900不是润年