+ 1
Why does my sum not summing up things? It's just showing 1, that is value of 1/b.
11 Antworten
+ 1
I can't give you the answer cause I won't interfere with your learning, specially because that's a great example of a real behavioral issue, I just gave an idea of how to debug this, so you can tweak it and fix it.
+ 1
Parth Salat, DON'T CLICK THE LINK BELOW if you want to continue trying to fix it on you own like Roberto Guisarre rightly suggested. Try, try!
https://code.sololearn.com/csSAOYe60uIT/?ref=app
+ 1
MEET MEHTA Was I right or could my code have been better? I know only the basics of the basics of Java.
+ 1
he just wants the sum right?
+ 1
Yes
+ 1
That's wht my code gives.
+ 1
He wants in this form
https://code.sololearn.com/cVb8Q2xxThks/?ref=app
+ 1
ok i got it.
0
Please consider that there will be no print until the "count" reaches the while condition, this is why you get the last result print, so I would print inside the "do" instead of after the while to see more clearly what's happening, or work with a "while" instead of a "do while". The second thing is that you may not need the "count variable when you can use the "b" variable in the while condition, but you hit an interesting analysis riddle there. Good luck Parth.
0
Roberto Guisarre Thanks for the answer but its still not working
0
I had fixed the code and its working as you want.
If you cant fix it post here I will be happy to share code with you.