Campbell Ritchie wrote:If you get stuck ask for help. I hope the version with the limits is there somewhere.
Campbell Ritchie wrote:I can use my utility class to get an input that is an int in the range 1...7 like this
Randy Tong wrote:After int s3 = scan.nextInt(); , add this lineIt helps in clearing out the buffer.
Campbell Ritchie wrote:You appear to be changing “bottlesȁ to “bottle” one line too late; go through the loop and work out where the best place for that change would be. Otherwise I can't see anything wrong with the output.
Don't use \n; use the printf() method and %n for line end.
Campbell Ritchie wrote:No, don't tweak the code. Read it out. Copy it onto a sheet of paper. Count the variables with your fingers. Or any combination of the preceding, until you work out what I meant. Then you will be able to correct it is a few seconds, and you will have learnt lots about reading code.
Campbell Ritchie wrote:You are reading the input correctly, but because you applied it to a different variable, the number used in the song is still 99.
Campbell Ritchie wrote:Welcome to the Ranch
Have you found the documentation for Scanner? There is an example just like what you want near the beginning of that documentation.