import java.io.*;

public class ArithmEx4
{
  public static void main(String[] args) throws IOException
  {
     int number = 0;

     try
     {
       System.out.print("Enter a number: ");
       number = getNumber();
       System.out.println("The number is " + number);
     }
     catch (MyException e)                   // catching a custom exception
     {
       System.out.println(e);
     }
  }

// this method rethrows the IOException and throws the custom exception
// of type MyException
  public static int getNumber() throws IOException, MyException
  {
     int number;
     BufferedReader keyboard = new
       BufferedReader(new InputStreamReader(System.in));
     try
     {
       number = Integer.parseInt(keyboard.readLine());
       // the above line might throw IOException (readLine) and
       // NumberFormatException (parseInt)
     }
     catch (NumberFormatException e)         // catching a Java API exception
     {
       MyException ee = new MyException();   // instantiate MyException
       throw ee;                             // throw the custom exception
     }
     return number;
  }
}

// declaration of a custom exception
class MyException extends RuntimeException
{
   public MyException()
   {
      super("Something is wrong...");        // never use "descriptions" like that		
   }

   public MyException(String s)
   {
      super(s);
   }
}

