0
Why does my code wont run in Code Playground?
I used the app JVdroid on my phone as an IDE. My code runs on my phone, but as I tried copy-paste it on Eclipse and in Sololearn Playground it suddenly wont run and shows errors. Why is this? I actually wanted to ask help on my code cause it keeps looping the statement "Enter an integer:" This is my code: https://code.sololearn.com/cb4sfREBu71i
4 Antworten
+ 5
Eka
Sololearn supports multiple inputs only once means you have to take all inputs together with separate lines so don't pass scanner object in method, just take input before calling method then pass integer input in method to add in list.
https://code.sololearn.com/cT0fCRf8Jrar/?ref=app
+ 2
Eka
I have done some changes according to me but I explained you problem and provided solution.
To ignore negative values you can check
if (num > 0) {
//Add in list
}
if (num == 0) {
//break loop to ignore more inputs
}
Check code again.
+ 1
AJ
Thank you so much, you’re a great help
0
AJ
The code you sent is great, but sadly, it no longer ignores the negative numbers and would stop. My code should ignore the negative numbers, and only stops on zero (sentinel value). I have another post to clear the confusion. https://www.sololearn.com/Discuss/2928264/how-to-ignore-negative-numbers