I\'m currently creating my first game which is executed in a console.
I\'ve been asked to validate an input which can be done with a simple code. The goal is to inpu
Because you instantiate input
to be 0
, but never give the user an opportunity to change this, the conditions for the first two conditionals are always false (nothing is read from the Scanner and 0 is not between min
and max
). Therefore, the program falls through to the else
every time. Just add a statement before the do-while
that will obtain a value for input
from the user.
input = scanner.nextInt();
// your do-while loop
(You'll also probably have to adjust the code slightly to get the type of interaction you're looking for. Hint - you're reading two values from the user.)