9 Answers
New Answer9 Answers
New AnswerYou don't add the first value to sum. Just throw it away. Don't save it to a variable. It is just the number of inputs that will follow. That's why I said to re-read the code coach and see what the inputs are.
You're adding the first input as if it is part of the list. Re-read the challenge and pay attention to what the inputs are. Handle the first input correctly and you should have it solved.
You just need to get the first input before the while loop and dispose of it as your while loop already takes care of the rest. Add sc.nextInt(); Before the loop. It doesn't need to be stored into an int, and it should pass all test cases.
I am so Stupid.I should have readed what inputs are properly.I was frustated for So long for nonsense. Thank you for your help.You are very helpful.I had just now followed you.
Please tell briefly what i need to change in the code as it is already only adding even integers.And How can i Change it.
If I gets the first input before the while loop and classifies it as even or odd out of while loop.And Then adds it to the sum.It still shows that case 4 and case 5 are wrong Please Help! https://code.sololearn.com/c4Jdl8is18kN/?ref=app
You didn't declare Variable i and so the compiler doesn't know what it is. It's that simple Solution:- Just initialise variable i like this. int i= 9 /* the value can be changed to whatever integer you choose */
Learn Playing. Play Learning
SoloLearn Inc.
4 Embarcadero Center, Suite 1455Send us a message