• Post Reply Bookmark Topic Watch Topic
  • New Topic

i am struggling with a variable to complete teh code  RSS feed

 
Dmitri Makovetskiy
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am stuck on the last part, . my task is to print all the numbers put into the applications which are smaller than the sum.

the last part is problematic..what the last part should do is count through all the characters in teh string "All", and save the numbers before dot. then convert those numbers and compare them to the average..




(I edited the code so that it isn't three times as wide as my screen -- PC)
 
Siddhesh Deodhar
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Dmitri, way in which this code has been written is horrible. It becomes very difficult to grasp for the new person ,what is going on in the code and what's the goal of writing code.
Please use proper variable names while writing the code.
Make indentation proper.

Regarding your problem, it looks like you have confused logic in your last for loop. I feel

Should be done if


is something other than a comma(i.e. your variable dot )
that is what I can see from this code.Try it out.
 
Dmitri Makovetskiy
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could you be clear in how i should rearrange the code.

what should be my if sentence and what in the else sentence?
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you define the variable 'sNumber' and what is the data type - a String??

Remember to set 'sNumber' to an empty String after you have used it in else...
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your above code is now working - if you (as I wrote it my last post) set 'sNumber' to an empty String after you have used it in else (set it inside else).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!