+ 1

Why does my sum not summing up things? It's just showing 1, that is value of 1/b.

https://code.sololearn.com/c07Nvs1H71Ci/?ref=app

19th Jul 2018, 11:58 AM
Parth Salat
Parth Salat - avatar
11 Answers
+ 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.
19th Jul 2018, 12:45 PM
Roberto Guisarre
Roberto Guisarre - avatar
+ 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
19th Jul 2018, 1:07 PM
Satyam
+ 1
MEET MEHTA Was I right or could my code have been better? I know only the basics of the basics of Java.
19th Jul 2018, 1:20 PM
Satyam
+ 1
he just wants the sum right?
19th Jul 2018, 1:29 PM
Satyam
+ 1
Yes
19th Jul 2018, 1:35 PM
Meet Mehta
Meet Mehta - avatar
+ 1
That's wht my code gives.
19th Jul 2018, 1:35 PM
Satyam
19th Jul 2018, 1:37 PM
Meet Mehta
Meet Mehta - avatar
+ 1
ok i got it.
19th Jul 2018, 1:37 PM
Satyam
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.
19th Jul 2018, 12:38 PM
Roberto Guisarre
Roberto Guisarre - avatar
0
Roberto Guisarre Thanks for the answer but its still not working
19th Jul 2018, 12:41 PM
Parth Salat
Parth Salat - avatar
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.
19th Jul 2018, 1:18 PM
Meet Mehta
Meet Mehta - avatar