Catching Errors

If you can prevent an error from occurring, it is much better. For instance you can always avoid a divide by zero error by testing with a statement such as if(divisor!=0) before dividing.

However, there are sometimes situations when you need to catch an error.

Please study the material at each of the links below.

  1. Reading integers
  2. Reading doubles
  3. Finding a total
  4. Input a date as mm/dd/year
  5. Check for leap year
Like us on Facebook:

OER: Open Educational Resource
Creative Commons License Author: Janet E. Joy; Publisher:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
Creative Commons Attribution-NonCommercial 4.0 International License
Last modified: May 18 2017 14:04:13.