Subhash
Subhash
Originally posted by David Harkness:
Finally, welcome to JavaRanch!
[ January 31, 2005: Message edited by: David Harkness ][/QB]
Subhash
Originally posted by Michael Dunn:
>I am having a hard time thinking about the best way to make it work
>recursively no matter how many digits the input number is, but I am getting stuc!!
this might be one way
check for the first comma - indexOf() (if < 0 make it length of string)
if the length of the string && firstComma are both > 3, call recursively with
new StringBuffer(str).insert(firstComma-3,",").toString()
Subhash
Originally posted by Michael Dunn:
>Branching off that idea, would this work?
I didn't get past this line
public int putCommas(String n)
I thought you were trying to recursively add commas, returning the String (with commas)
i.e. the return value should be a String
This is the way I put it together
Subhash
Originally posted by Michael Dunn:
>Branching off that idea, would this work?
I didn't get past this line
public int putCommas(String n)
I thought you were trying to recursively add commas, returning the String (with commas)
i.e. the return value should be a String
This is the way I put it together
Subhash
Originally posted by Steven Bell:
Hmm, I ran this and it worked.
Subhash
Originally posted by Ernest Friedman-Hill:
Mr. S --
Welcome to JavaRanch!
You may not have read our naming policy on the way in. It reqiures that you use a full, real (sounding) first and last name for your display name. Initials aren't enough. You can change your display name here. Thanks!
Subhash
Originally posted by David Harkness:
I hate to be the bad guy here, but when did we stop helping people learn and start running a homework service?
Subhash
Originally posted by David Harkness:
I hate to be the bad guy here, but when did we stop helping people learn and start running a homework service?
Subhash
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |