- import java.util.Scanner;
- public class ch46
- {
- public static void main(String args[])
- {
- try
- {
- int a, b;
- Scanner s=new Scanner(System.in);
- System.out.println("請輸入分子: ");
- a=s.nextInt();
- System.out.println("請輸入分母: ");
- b=s.nextInt();
- System.out.println(a+" / "+b+" = "+a/b);
- }
- catch(Exception e)
- {
- System.out.println("出現例外: "+e.toString[]);
- }
- }
- }
複製代碼 |