返回列表 發帖
  1. package bn.tw;

  2. import java.util.Scanner;

  3. public class Main {

  4.         public static void main(String[] args) throws My_Exception {
  5.                 // TODO 自動產生的方法 Stub
  6.                 Scanner scanner = new Scanner(System.in);

  7.                 System.out.println("分母");
  8.                 int num1 = scanner.nextInt();
  9.                 System.out.println("分子");
  10.                 int num2 = scanner.nextInt();
  11.                 int result = 0;
  12.                 if (num1 != 0) {
  13.                         result = num2 / num1;
  14.                 } else {
  15.                         throw new My_Exception("分母不可為0");
  16.                 }

  17.         }

  18. }
複製代碼

TOP

返回列表