- import java.util.Scanner;
- public class ch51
- {
- public static void main(String args[])
- {
- Scanner s=new Scanner(System.in);
- int a,b;
- try
- {
- System.out.print("請輸入分子: ");
- a=s.nextInt();
- System.out.print("請輸入分母: ");
- b=s.nextInt();
- System.out.print(a+"/"+b+"="+a/b);
- }
- catch(Exception e)
- {
- System.out.println("程式發生錯誤!");
- System.out.println("例外類別: "+e.toString());
- }
- }
- }
複製代碼 |