Now, let’s consider a simple example of exception handling. The app in Fig. 13.2 uses exception handling to process any
FormatExceptions that might arise. The app reads two integers from the user (lines 18–21). Assuming that the user provides integers as input and does not specify
0 as the denominator for the division, line 25 performs the division and lines 28–29 display the result. However, if the user inputs a noninteger value or supplies
0 as the denominator, an exception occurs. This program demonstrates how to catch and handle such exceptions—in this case, displaying an error message and allowing the user to enter another set of values.