阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。 【说明】本程序ExceptionTester实

题目

阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。

【说明】本程序ExceptionTester实现功能:读入两个整数,第1个数除以第2个数,之后输出。若第2个数为0,则自动进行异常处理。

程序如下:

(1);

public class ExceptionTester{

public static void main(String args[]){

int result;

int number[]=new int[2];

boolean valid;

for(int i=0;i<2;i++){

valid=(2);

while(!valid){

try{

System.out.println("Enter number"+(i+1));

number[i]=Integer.valueOf(Keyboard.getString()).intValue();

valid=true;

}catch(NumberFormatExceptione){

System.out.println("Invalid integer entered.Please try again.");

}

}

}

by{

result=number[0]/number[1];

System.out.print(number[0]+"/"+number[1]+"="+result);

}catch((3)){

System.out.println("Second number is 0,cannot do division!");

}

}

}

其中,Keyboard类的声明为:

impon java.io.*;

public class Keyboard{

static BufferedReader inputStream=new (4)

(new InputStreamReader(System.in));

public static int getInteger(){

try{

return(Integer,valueOf(inputStream.readLlne().trim()).intValue());

}catch(Exceptione){

e.printStackTrace();

return 0;

}

}

public (5) {

by{

return(inputStream.readLine());

} catch(IOExceptione)

{return "0";}

}

}

更多“阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。 【说明】本程序ExceptionTester实 ”相关问题