3.2) Exercise 5
- Open the example program kbinput.cpp in your text editor and examine it.
- Compile and run the program. When prompted, enter two numeric values, separated by a space. Repeat this a few times for different numeric values. Try specifying a number using scientific notation - e.g., 7.5e-2. In each case, you should find that the values are read correctly and that the result of calling the
fail
method oncin
is 0, indicating no errors. - Run the program again and experiment with separating the two numbers in different ways. Try using multiple spaces or tabs. Try pressing the Enter key after typing a single number. You should see that the program waits for further input; you will need to supply a second number before it completes.
- Try entering a pair of numbers separated by something other than a space - e.g., a comma. Notice how the first number is read successfully but the second isn't. This time, the result of calling the
fail
method oncin
should be 1, indicating failure.