February 2017
Beginner
1056 pages
28h 57m
English
All short statements about programming techniques are false.
—ANONYMOUS
In this section, we present some programs that illustrate ways to use recursion.
The program in Listing 11.5 simply requests a positive integer and then counts down from that integer to zero. The method getCount reads the integer from the user. Notice that if the user enters a number that is not positive, the method getCount calls itself. This call starts the input process all over again from the beginning. If the user enters another incorrect number, another recursive call occurs, and the input process will start yet again. This procedure is repeated until the user enters a positive ...
Read now
Unlock full access