//TestExceptionHandling.java

import java.util.Scanner;
import java.util.Random;

public class TestExceptionHandling
{
    public static void main(String args[])
    {
        //Exception handling
        //==================
        //System.out.println(6/0);
	
        try
        {
            System.out.println(6/0);
        }
        catch (ArithmeticException e)
        {
            System.out.println(e.getMessage());
        }

        /*
        //Illustrating try-throw-catch
        Scanner keyboard = new Scanner(System.in);
        boolean finished = false;
        do
        {
            try
            {
                System.out.print("\nEnter an integer: ");
                String input = keyboard.nextLine();
                int inputAsInt = Integer.parseInt(input);
                System.out.println("The value of 6 / " + inputAsInt
                    + " is " + (6 / inputAsInt) + ".");
                System.out.print("Enter another value to divide? [y/[n]] ");
                String response = keyboard.nextLine();
                if (!response.equalsIgnoreCase("y")) finished = true;
            }
            catch (ArithmeticException e)
            {
                System.out.println(e.getMessage() + "\nCan't do that!"
                    + "\nTry again.");
            }
            catch (NumberFormatException e)
            {
                System.out.println("The number you entered was not an "
                    + "integer.\nTry again.");
            }
        }
        while (!finished);
        */
    }
}

