Listing 2-9 - Responding to user input