February 2014
Beginner
1248 pages
62h 25m
English
Any time a program receives input from the user, various problems might occur. For example, in line 20 of Fig. 4.8
int grade = input.nextInt(); // input next grade
we assume that the user will enter an integer grade in the range 0 to 100. However, the person entering a grade could enter an integer less than 0, an integer greater than 100, an integer outside the range of values that can be stored in an int variable, a number containing a decimal point or a value containing letters or special symbols that’s not even an integer.
To ensure that inputs are valid, industrial-strength programs must test for all possible erroneous cases. A program that inputs grades should validate ...
Read now
Unlock full access