   import java.util.Scanner;
   import java.util.*;

/**
 * Class purpose: Find exceptions and handle them
 * 
 * @author  Josh Rodgers
 * @version - V1
 * @date - January 17, 2007	
 * @section - 2
 * @lab - 3
 *
*/

/**************************************************
 *   In this program there are possiblities of 5  *
 *    different exceptions, they are listed       *
 *              in order below:                   *
 *                                                *
 *	1. InputMismatchException                      *
 * 2. ArrayIndexOutOfBoundsException              *
 * 3. ArithmeticException                         *
 * 4. StringIndexOutOfBoundsException             *
 * 5. NegativeArraySizeException                  *
 *                                                *
 **************************************************/
 
 
    public class Exceptions_Lab_rodgerjm_Junk
   {
       public static void main(String[] args)
      {
         int problem1;
         int problem2;
         int numberForArray2;
         int[] array1 = { 1, 2, 3 };
         int[] array2;
         int one = 1;
         int zero;
         int answer;
         String problem4;
         char outOfBounds;
      
      
         Scanner keyboard = new Scanner(System.in);
      
         try
         {
            System.out.print("Please enter a number" +
										"(any letters will cause an exception): ");
            problem1 = keyboard.nextInt();
            System.out.print("\n");
         }
         
             catch (InputMismatchException ime)
            {
               System.out.println("Input mismatched\n");
            }
      	
			keyboard.nextLine();
			
         try
         {	
            System.out.print("Please enter a positive number from 1 - 2" +
               					"\nto instantiate an array. " +
										"\n(a 3 or greater will cause an exception): ");
            problem2 = keyboard.nextInt();		
            System.out.println(array1[problem2]);
         }
         	
             catch (ArrayIndexOutOfBoundsException aoobie)
            {
               System.out.println("Array out of Bounds\n");
            }
      		
         try
         {
            System.out.print("Please enter a number(a zero will " +
               					"cause an exception): ");
            zero = keyboard.nextInt();
            answer = one / zero;
         }
         
             catch (ArithmeticException ae)
            {
               System.out.println("Divide by zero exception\n");
            }
      		
         keyboard.nextLine();
      	
         try
         {
            System.out.print("Please enter a string(any string " +
               					"less than\ntwenty characters will cause " +
               					"an exception): ");
            problem4 = keyboard.nextLine();
            outOfBounds = problem4.charAt(20);
         }
         
             catch (StringIndexOutOfBoundsException soobe)
            {
               System.out.println("The String is out of bounds\n");
            }
      
         try
         {
            System.out.print("Enter a number to instantiate an array\n" +
									  "(a negative number will cause an exception): ");
            numberForArray2 = keyboard.nextInt();
            array2 = new int[numberForArray2];
         }
         	
             catch(NegativeArraySizeException nase)
            {
               System.out.println("The array index is negative\n");
            }
      		
         System.out.println("The Program has ended, with a lot of Exceptions.");
      }
   }
