這是一份有關 exception handling 的作業

import java.util.InputMismatchException;
import java.util.Scanner; //user input number
import java.lang.Math; //for power calculate

public class Main {
	public static void main(String[] srgv) {
		int x, y; //store base and exponent
		Scanner input = new Scanner(System.in);
		while (true) {
			try {
				System.out.println("please input X"); //prompt input message
				x = input.nextInt(); //store base
				System.out.println("please input y"); //prompt input message
				y = input.nextInt(); //store exponent
				Power(x, y); //use power method
			}catch(InputMismatchException e) { //reference: https://stackoverflow.com/questions/24857070/try-catch-inside-while-loop
				System.out.println("Error!it’s not integer\n");
				input.next(); //clear scanner
			}
		}
	}
	public static void Power(int base, int exponent) {
		try{
			if(base == 0 && exponent == 0) {
				throw new exception1();
			}
			if(exponent < 0) {
				throw new exception2(base, exponent);
			}
			int result = (int) Math.pow(base, exponent); 
			System.out.println("the answer is: " + result);
		}catch(exception1|exception2 e) {
			
		}finally {
			System.out.println(); //LF
		}
	}
	
}

class exception1 extends Exception{
	public exception1() {
		System.out.println("Error! zero to the power of zero is not defined  0^0 is not integer"); //hint
	}
}

class exception2 extends Exception{
	public exception2(int base, int exponent) {
		System.out.println("Error!the exponent is negative value  " + base + "^" + exponent + " is not integer"); //hint
	}
}