No, because "yes" is not exactly equal to "y" .
The program could also use the startsWith( String prefix )
method of String
.
Here is the program with some additional work done on the "prompting
and looping" aspect.
The program is written so that the loop body always executes at least once.
In its first execution, it asks the user for x
and prints out
the value of the polynomial.
Then, at the bottom of the loop, it asks if it should continue.
Review (of Chapter 12): the next()
method of Scanner
returns the next token in the input stream.
By default, a token is a group of characters surrounded by white space.
Fill in the blanks.