返回列表 發帖
  1. package mhjh.mtc;

  2. import java.util.Scanner;


  3. public class WWW {

  4.         public static void main(String[] args) throws  MyException
  5.         {
  6.                 // TODO 自動產生的方法 Stub
  7.         Scanner scanner= new Scanner(System.in);
  8.         System.out.println("請輸入分子");
  9.         int num1=scanner.nextInt();
  10.         System.out.println("請輸入分母");
  11.         int num2=scanner.nextInt();
  12.         int result=0;
  13.      if(num2!=0){
  14.              result=num1/num2;
  15.      }
  16.      else{
  17.              throw new MyException("分母不可以為零");
  18.      }
  19.         }

  20. }
複製代碼

TOP

返回列表