public class OurMathDriver
1: /**
2: A demonstration of a runtime exception using the class OurMath.
3: @author Frank M. Carrano
4: @author Timothy M. Henry
5: @version 5.0
6: */
7: public class OurMathDriver
8: {
9: public static void main(String[] args)
10: {
11: System.out.print("The square root of 9 is ");
12: System.out.println(OurMath.squareRoot(9.0));
14: System.out.print("The square root of -9 is ");
15: System.out.println(OurMath.squareRoot(-9.0));
17: System.out.print("The square root of 16 is ");
18: System.out.println(OurMath.squareRoot(16.0));
19: } // end main
20: } // end OurMathDriver
21: /*
22: The square root of 9 is 3.0
23: The square root of -9 is Exception in thread "main" SquareRootException:
24: Attempted square root of a negative number.
25: at OurMath.squareRoot(OurMath.java:14)
26: at OurMathDriver.main(OurMathDriver.java:12)
27: */