请在每条横线处填写一个语句,使程序的功能为:判断输入的年份是否为闰年(例如:1998年不是闰年,2000年是闰年). 注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 import java.io.*;

admin2009-01-15  56

问题 请在每条横线处填写一个语句,使程序的功能为:判断输入的年份是否为闰年(例如:1998年不是闰年,2000年是闰年).
   注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。
      import java.io.*;
        public class LeapYear{
          public static void main(String args[]){
           ___________________;
           BufferedReader in;
        ir=new InputStreamReader(_____________________________);
        in=new BufferedReader(ir);
        System. out. print In("输入年份是:  ");
        String s=in.readline();
        int year=___________________
      if(year%4==0&&year%100!=0||year%400==0
        System.out.println(" "+year+" "年是闰年. ");
      else
        System.out.println(" " +year+ " "年不是闰年.");
         }
     }
  }

选项

答案InputStreamReader ir; System.in Integer.parseInt(S);

解析 本题主要考查I/O流。解答本题的关键是理解和使用I/O流。在本题中,InputStreamReader ir;语句的功能是声明一个字符输入流对象ir,ir=new InputStreamReader(System.in);语句的功能是生成一个字符输入流对象ir(InputStreamReader();方法以标准输入流对象为参数)。int year=Integer,parseInt(s);语句的功能是定义一个整型变量year,这里Integer是包装类,parseInt(s)方法是将字符串数据转换成整型数据。
转载请注明原文地址:https://kaotiyun.com/show/SIID777K
0

最新回复(0)