• Post Reply Bookmark Topic Watch Topic
  • New Topic

Efficient Loop ?  RSS feed

 
Wolfgang Obi
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
i'm having problems reorganising my programme,...some how seems disjointed, how could i organise it to be more efficient?

thx

-W.O.


output: <digit>---<digit>---<digit>---<digit>---<digit>
[ May 09, 2006: Message edited by: Wolfgang Obi ]
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey wolfgang,

what's your problem? is the output not as expected? what do you mean with "somehow it's disjointed"?

please clarify a bit more, then we can try to help you,

regards,
jan
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Try this one you have typo mistake instead of writing modHundreds you wrote modModhundreds
This will give you the desired Output Like for an example if natNum is 30052

then the output will be as follows:



here's the Output: 3---0---0---5---2


Hope this was as you want to get.....Hope it helps you.......


[ May 09, 2006: Message edited by: Ankur Sharma ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're concerned about how it reads, you can try a style that makes the code tell the reader what's going on as clearly as possible. Could you cast your code into something like:

Try to imagine computeAndShowDigits() done in the same style. Would you compute ones, tens, hundreds, etc? Or maybe work out a loop that could handle any number of digits without coding getHundredsOfThousands() and so on?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!