返回列表 發帖
  1. import java.util.Scanner;
  2. public class ch51
  3. {
  4.     public static void main(String args[])
  5.     {
  6.           Scanner s=new Scanner(System.in);
  7.           int a,b;
  8.           try
  9.           {
  10.               System.out.print("請輸入分子: ");
  11.               a=s.nextInt();
  12.               System.out.print("請輸入分母: ");
  13.               b=s.nextInt();
  14.               System.out.print(a+"/"+b+"="+a/b);
  15.           }
  16.           catch(Exception e)
  17.           {
  18.               System.out.println("程式發生錯誤!");
  19.               System.out.println("例外類別: "+e.toString());
  20.           }
  21.     }
  22. }
複製代碼

TOP

返回列表