package bbb; import java.util.Scanner; public class ExceptionTste { public static void main(String[]args){ int x,y; float sum = 0; System.out.println("请输入除数"); Scanner x1=new Scanner(System.in); Scanner y1=new Scanner(System.in); x=x1.nextInt(); y=y1.nextInt(); try{ sum=x/y; }catch(Exception e){ e.printStackTrace(); } finally{ System.out.println(sum); } System.out.println("program over"); } }
package bbb; import java.util.Scanner; public class Yuan { public static void main(String[]args){ double r,s=0; System.out.println("请输入圆的半径"); try{ Scanner r1=new Scanner(System.in); r=r1.nextInt(); s=r*r*3.14; }catch(Exception e){ e.printStackTrace(); } finally{ System.out.println(s); } System.out.println("program over"); } }