返回列表 發帖
  1. import java.util.Scanner;


  2. public class Ch01 {

  3.         public static void main(String[] args) {
  4.                 for(;;)
  5.                 {
  6.                         try
  7.                         {
  8.                                 Scanner s=new Scanner(System.in);
  9.                                 int x,y;
  10.                                 System.out.print("輸入x:");
  11.                                 x=s.nextInt();
  12.                                 System.out.print("輸入y:");
  13.                                 y=s.nextInt();
  14.                                 System.out.println(x+"/"+y+"="+x/y);
  15.                         }catch(Exception e)
  16.                         {
  17.                                 System.out.println("程式發生錯誤");
  18.                                 System.out.println("例外類別:"+e.toString());
  19.                         }
  20.                 }

  21.         }

  22. }
複製代碼

TOP

返回列表