How many integers do we take as input here?
There is no definite value, as in other questions.
Simple input problem. Question Unclear
you need to take input this till sum doesnt become negative and has input
or you can just add while (sum >= 0 && scn.hasnext)
if this solves your doubt please mark it as resolved 