Why does my code wont run in Code Playground? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

22nd Nov 2021, 3:17 PM
Eka
Eka - avatar
4 Answers
+ 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
22nd Nov 2021, 3:37 PM
A͢J
A͢J - avatar
+ 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.
23rd Nov 2021, 3:03 AM
A͢J
A͢J - avatar
+ 1
AJ Thank you so much, you’re a great help
23rd Nov 2021, 3:16 AM
Eka
Eka - avatar
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
23rd Nov 2021, 2:53 AM
Eka
Eka - avatar