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

TOP

返回列表