// This is a user defined exception class extends Exception class
// This program read a number between 1 and 100, creates/generates your own exception if number is outside the range
import java.util.Scanner;
class MyException extends Exception {  
    	public MyException(int i) {  
    	    	System.out.println("You entered " +i+ " ,outside the range(1-100)");  
    	}  
}  
  
public class ExceptionTest{  
    	public void show(int i) throws MyException{  
        	if(i > 100 || i < 1)  
            		throw new MyException(i);  
        	else  
        	    	System.out.println(+i+ " is within the range(1-100)");  
    	}  
  
    	public static void main(String[] args){  
		Scanner obj = new Scanner(System.in);
       		System.out.println ("Enter the value for a");
        	int a = obj.nextInt();  	      

        	ExceptionTest t = new ExceptionTest();  
        	try{  
            		t.show(a);            
        	}catch(Throwable e) {  
           		System.out.println("Catched exception is " +e);  
        	}  
    	}  
}  
