- package bn.tw;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) throws My_Exception {
- // TODO 自動產生的方法 Stub
- Scanner scanner = new Scanner(System.in);
- System.out.println("分母");
- int num1 = scanner.nextInt();
- System.out.println("分子");
- int num2 = scanner.nextInt();
- int result = 0;
- if (num1 != 0) {
- result = num2 / num1;
- } else {
- throw new My_Exception("分母不可為0");
- }
- }
- }
複製代碼 |