本题提示输入年份,然后判断该年份是否为闰年。
import java.io.*;
public class java1
public static void main(String[]args)
InputStreamReader ir;
BufferedReader in;
ir=new InputStreamReader(System.in);
in=new BufferedReader(ir);
int year=1900;
System.out.print("请输入年份:");
try
String s=in.readLine();
______;
______(Exception e)
if(______)
System.out.println(year+"是闰年");
else
System.out.println(year+"不是闰年");
参考答案:第1处:year=Integer.parseInt(s)
第2处:catch
第3处:year%4==0&&year%100!=0||year%400==0
解析: 第1处是将String型的s转换成整型;第2处是捕获异常的catch子句,用来处理由try所抛出的异常事件;第3处是判断是否为闰年的条件,即能被4整除且不能被100整除的或能被400整除的就是闰年。