自己无聊写的,着重运用了三元运算,一个小DEMO
将就着看吧大家
import java.util.Scanner;
/**
*
* @author ULTIGA
* 判断一个年份是平年还是闰年
*
*/
public class pingnianrunnian {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int year = sc.nextInt();
Boolean flag = (year%4 == 0 && year%100 != 0 ) ? true : (year%400 == 0 ? true : false);
if(flag) {
System.out.println(year+"年是闰年!");
}else {
System.out.println(year+"年是平年!");
}
}
}