October 2017
Beginner
318 pages
7h 26m
English
At the beginning of this chapter, I promised you'd learn about conditional statements, and we're about to do that now. But first, let's make a quick modification to the user input portion of our program. Rather than acquiring a string, it's going to be a lot easier if we learn conditional statements working with a user-provided integer value. So let's change the value or the type of our input variable to an int datatype; the reader.next() function returns a string, but there's a similar function called nextInt() that will return an integer:
int input = reader.nextInt();
We're certainly not going to bother putting any error-handling mechanism in our very simple program.
Read now
Unlock full access