I notice that you're doing this call:
decPlace = input.nextInt();
The return character isn't consumed, so it is still on the buffer as far as the Scanner
is concerned.
This means, for an input of 2\n
, it will read the 2 as the next integer, but read an empty string for the call to nextLine()
.
To get past this, finish consuming the line by using input.nextLine()
after you read the next integer.
decPlace = input.nextInt();
input.nextLine();