JMU
Going Further with Exception Handling


In the lab on experimenting with exception handling, you used the following application.
Example4.java

These questions/tasks will allow you to go further with some of the topics that were raised in that lab.

1 Making the Application Useful

Before going any further, make the application (at least somewhat) useful by modifying it so that it supports addition (+), subtraction (-), multiplication (*), and division (/).

Note: Don't add functionality to allow it to process complicated expressions involving more than one operation. While interesting, that task is unrelated to the topics addressed in the lab.

2 Batch Processing

As it is currently written, this application can only process one expression (i.e., command line argument) at a time. In other words, modify the applicationso that it processes all of the command line arguments rather than just args[0]. (Your program should treat each command line argument as a different expression to evaluate. So, for example, it should be able to be executed as follows: java Example4 5.0+4.1 3.2*9.1.

3 Better Error Messages

Modify the application so that it tells you which operand is not a number. (Hint: You may need to use nested try-catch blocks.)

Copyright 2015