An appropriate sentinel value may not exist.
If the previous program processed all integers - negative as well as non-negative, there are no integer values left to use as a sentinel.
The hasNext family of Scanner methods can be used to detect end of input.
Note that hasNextInt() will return false at end of input or if the next input is doesn't represent an int.
The hasNext methods return false instead of throwing an exception if the input is not what is expected.