请在每条横线处填写一个语句 使程序的功能为:判断输入的年份是否为闰年(例如:1998年不是闰年 200

计算机 闰年,横线,语句 已帮助 人

请在每条横线处填写一个语句,使程序的功能为:判断输入的年份是否为闰年(例如: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+ " "年不是闰年.");

}

}

}

请帮忙给出正确答案和分析,谢谢!

热搜:一个c程序的执行是从本程序的main函数开始

答案解析

难度★★☆ 搜索
  • 正确答案:InputStreamReader ir; System.in Integer.parseInt(S);
    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)方法是将字符串数据转换成整型数据。