第五次作业
1 package Exception; 2 import java.util.Scanner; 3 public class ExceptionTest 4 { 5 public static void main(String[] args) 6 { 7 Scanner sc=new Scanner(System.in); 8 try 9 { 10 System.out.println("请输入两个数:"); 11 int x=sc.nextInt(); 12 int y=sc.nextInt(); 13 int z=x/y; 14 System.out.println("这两个数相除结果为:"+z); 15 16 } 17 catch(ArithmeticException e) 18 { 19 20 e.printStackTrace(); 21 } 22 finally 23 { 24 System.out.println("程序运行结束!"); 25 } 26 sc.close(); 27 28 } 29 }