程序代码:
public class JavaSeven { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try{ double d0=Double.parseDouble(args[0]); double d1=Double.parseDouble(args[1]); if(d1==0)throw new ArithmeticException(); double result=d0/d1; System.out.println(result); }catch(ArithmeticException ae){ System.out.println("除数不能为零!"); }catch(NumberFormatException nfe){ System.out.println("请输入两个小数!"); } } }
时间: 2024-12-18 17:16:14