- import java.util.*;
- public class Queen
- {
- public static void main(String args[])throws MyException
- {
- int a,b;
-
- Scanner s=new Scanner(System.in);
- System.out.print("輸入分子:");
- a=s.nextInt();
- System.out.print("輸入分母:");
- b=s.nextInt();
- if(b==0)
- {
- throw new MyException("嘿嘿嘿~分母不可為0喔~");
- }
- System.out.print(a+"/"+b+"="+(a/b));
-
- }
-
- }
- class MyException extends Exception
- {
- MyException (String str)
- {
- super(str);
- }
- }
複製代碼 |