java编程 100以内的除法运算

1.如果除数为零,抛出异常
2.如果大于100,抛出TooLargeException异常
3.如果不是数字,抛出格式问题

java中没有TooLargeException这个异常

public void division (int number) throws Exception{
if(number==0){
throw new Exception();
}else if(number>100){
throw new IllegalStateException();
}else{
for(int i=1;i<=100;i++){
System.out.println(i+"/"+number+"="+(i/number));
}
}
}
温馨提示:答案为网友推荐,仅供参考
大家正在搜