Next page | Contents page |

Exercise 10 - Exception handling

In exercise 2 we deliberately made Squarer fail, with some unreasonable inputs. Now modify the code so that the exceptions are handled to give the user sensible messages about what happened, rather than the bland or rather technical standard system messages about XYZExceptions occuring.

Remember that integer overflow is not detected as an exception but nevertheless include some code to detect that and tell the user.

Next page | Contents page |