Due by the end of Tuesday, 16 March 2021
For example, mix some double numbers to crash the program:
Modify the program to catch this specific exception (InputMismatchException) so that whenever the program sees an invalid value, it first prints out an error message to the console, and it assigns -1 to that array element. Of course, if the value entered is valid, you must use that value.
Sample output:
HINT: You will probably need to "flush" Scanner buffer using nextLine() in the catch-block to avoid the unwanted outcome.
NOTE: We have already seen Rectangle classes that throw exceptions. The only difference is that this time we are throwing an exception from a user-defined class. Do not let that throw you!Test your revision using the program TestRectangle.But do notice that this time we are allowing zero-sided Rectangles.
If you've got it right, you should see output very much like this:
Submit this/these files:
You will be graded on the following: