- import java.util.Scanner;
- public class Ch51
- {
- static Scanner s=new Scanner(System.in);
-
- public static void main(String[] args) throws MyException
- {
- float x,y;
- System.out.print("輸入分子: ");
- x=s.nextFloat();
- System.out.print("輸入分母: ");
- y=s.nextFloat();
- if(y==0)
- throw new MyException("嘿嘿嘿~分母不可為零喔!");
- System.out.println(x+"/"+y+"="+(x/y));
- }
- }
複製代碼 |