A Deeper Look at Receiving User Input
Any time a program receives input from the user various problems might occur. For example, in line 53 of Fig. 4.7
cin >> grade; // 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 the user’s input is valid, industrial-strength programs must test for all possible erroneous cases. As you progress through the book, you’ll learn various techniques for dealing with ...