Assignment 7
Up Assignment 1 Assignment 2 Assignment 3 Assignment 4 Assignment 5 Assignment 6 Assignment 7 Assignment 8 Assignment 9 Assignment 10

 

Exceptions: When Something Goes Wrong

Due: Monday, Nov 5, 5:00 PM

 

Read Section 11.13 (on "checked" and "unchecked" arithmetic).  Then, starting with my solution to Assignment 4a, which is in the Solutions folder (i.e. the program that performs exponentiation), do the following:

  1. Modify the IntegerPower method so that it performs checked multiplication.
     
  2. Modify the CalculateButton_Click method so that it looks for and recovers from two kinds of exceptions: FormatExceptions and OverflowExceptions.  The exception handlers should display a MessageBox with a distinct error message to indicate the error to the user.

Note: int.Parse and long.Parse also generate an OverflowException when the input string being parsed is too big to be an int or long, respectively.  Write your code so that it distinguishes (by displaying a different error message) between the case that int.Parse or long.Parse throws the exception, and IntegerPower throws the exception (i.e. in one case the input is too big, in the other case the result is too big).