   import java.util.Scanner;
   import java.io.*;
/***********************************************
 * To try to catch exceptions
 *
 * @author - Jacob Ewers
 * @version - V1 - 01/17/06
 * Lab 3
 * Section 1
 * exception list:
 *    ArrayIndexOutOfBoundsException
 *		ArithmeticException
 *		InputMismatchException
 *		FileNotFoundException
 *		ParseIntException
 ************************************************/
 /*
 /  References and Ackknowledgements: I have recieved
 /  no help on this programming assignment
 /
 /***********************************************/
    public class Exceptions_Lab_ewersjl_tryCatch 
   {
   /********************************************
    * To cause exceptions and catch them
    *
    * @param args         - unused
    *********************************************/
       public static void main(String args[])
      {
      	// Declarations
         Scanner keyboard;
         keyboard = new Scanner(System.in);
         Scanner fileScanner;
         

      
      	//a for loop to take the array out of bounds
         int[] myArray;
			myArray = new int[10];
			
			for (int index = 0; index <= 10; index++) 
         {
            try
            {
               System.out.print("Enter a number for the new array.");   //to get the numbers
               myArray[index] = keyboard.nextInt();
               System.out.println("The number you entered is " + myArray[index] + ".");//echo input
            }
                catch(ArrayIndexOutOfBoundsException aioobe)
               {
                  System.out.println("\nThere can only be ten integers in this array. ");
               }
         
         }
         System.out.println("\n\n");
      
      	//ask for two ints to be devided and might get ArithmeticException
			int enteredInt1, enteredInt2, intAnswer;
			
         System.out.print("Enter the numarator for a division problem. ");
         enteredInt1 = keyboard.nextInt();
         System.out.println("The numarator is " + enteredInt1 + ".");		//echo input
         System.out.print("Enter the denominator for a division problem. ");
         enteredInt2 = keyboard.nextInt();
         System.out.println("The denominator is " + enteredInt2 + ".");		//echo input
      
         try
         {
            intAnswer = enteredInt1 / enteredInt2;
            System.out.println("The answer is " + intAnswer + ".");
         }
             catch (ArithmeticException ae)
            {
               System.out.println("\nYou cannot devide by zero.");
            }
         System.out.println("\n\n");
      
      
      	//try catch block for a string going in a double
      	double enteredDouble;
         enteredDouble = 0;   			//so the value is intialized
			String fileName;
      
         try
         {
            System.out.print("Enter a string. ");
            enteredDouble = keyboard.nextDouble();
            System.out.println("Your string is: " + enteredDouble);			//echo input
         }
             catch (java.util.InputMismatchException ime)
            {
               System.out.println("Your string is: " + enteredDouble);			//echo input becuase if try fails it will come here
               System.out.println("\nA string can not go into a double value. ");
            }
         System.out.println("\n\n");
      
      
         keyboard.nextLine();     //to flush the keyboard
      	
         System.out.print("Enter the name of a file. ");
         fileName = keyboard.nextLine();
         System.out.println("The file choosen is " + fileName + "."); 		//echo input
      
      	//try catch block to go a nonexistent file
         try
         {
            fileScanner = new Scanner (new File (fileName));	//to instansiate fileScanner
            fileScanner.hasNext();
         
         }
             catch (FileNotFoundException fnfe)
            {
               System.out.println ("\nYour file was not found. ");
            }
         System.out.println("\n\n");
      
      
      	//try catch block to get a ParseIntException
         int parseValue;
			String enteredString;
      
         System.out.print("Enter your favorite letters to see if they can be parsed. ");
         enteredString = keyboard.nextLine();
         System.out.println("You entered " + enteredString + ".");      //echo input
      
         try
         {
            parseValue = Integer.parseInt(enteredString);
         }
             catch (NumberFormatException nfe)
            {
               System.out.println("\nYour letters cannot be parsed.");
            }
      
      
         System.out.println("\n\nThis program has ended normally.");
      }	
   
   }  
