import java.io.*; // catching Exceptions - if one of the students ct is 0 the program will not crash // because the predefined Exception is caught public class testexceptions {public static input in = new input(); public void enter() throws IOException { for (int x=1; x <=3; x++) // enter 3 students grades { int n,sum=0, ct = 0; System.out.println("Enter a number or -1 to end"); n = in.getInt(); while (n != -1) { sum += n; ct++; System.out.println("Enter a number or -1 to end"); n = in.getInt(); } try { double avg = sum /ct; System.out.println("Average is "+avg); } catch(ArithmeticException ae) {new Exception("Can't divide by zero."); } } // for } // enter }