import java.util.Scanner;
import java.io.*;
public class Exceptions
{
	public static void main(String[] args)
	{
		Scanner keyboard;
		keyboard = new Scanner(System.in);
		FileReader freader;
		String file;
		System.out.print("What file would you like to open: ");
		file = keyboard.nextLine();
		/*This statement will throw a fnfe exception*/
		freader = new FileReader(file);
		/*This try/catch block will handle the fnfe*/
		try
		{
			freader = new FileReader(file);
		}
		catch (FileNotFoundException fnfe)
		{
			System.out.println("The file you were trying to open " + file + " could not be found");
		}
		
		/*This code will throw an aoobe*/
		int[] num;
		int length;
		num = [1, 2, 3, 4, 5];
		length = num.length;
		for (int counter = 0; counter <= length; counter++)
		{
			System.out.println(num[counter]);
		}
		
		/*This try/catch block will handle the aoobe*/
		try
		{
			System.out.println(num[counter]);
		}
		catch (ArrayOutOfBoundsException aoobe)
		{
			System.out.println("The array index you were trying to reference is out of bounds");
		}
		
		/*This code will throw a Not a Number exception*/
		int nan;
		nan = (3 / 0);
		
		/*This try/catch block will handle the nan exception*/
		try 
		{
			nan = (3 / 0);
		}
		catch (NotANumber NaN)
		{
			System.out.pritnln("The variable you were refering to references not a number");
		}
		
		String abc;
		abc = "alphabet";
		
		/*This code throws a conversion exception*/
		int bake;
		bake = (int)abc;
		
		/*This code handles the conversion exception*/
		try
		{
			bake = (int)abc;
		}
		catch (ConversionException ce)
		{
			System.out.println("The conversion you tried to do created a non-number");
		}
		
	}
}