- package mhjh.mtc;
- import java.util.Scanner;
- public class WWW {
- public static void main(String[] args) throws MyException
- {
- // 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(num2!=0){
- result=num1/num2;
- }
- else{
- throw new MyException("分母不可以為零");
- }
- }
- }
複製代碼 |