- import java.util.Scanner;
- public class ch49
- {
- 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.print("程式發生錯誤!");
- System.out.print("例外類別:"+e.toString());
- }
- }
- }
複製代碼 |