This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Cattle Drive and the fly likes Java 4b end commas Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Java 4b end commas" Watch "Java 4b end commas" New topic
Author

Java 4b end commas

jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Well, I actually got me code working with 4B, and am on the brink of sending it in. The only problem I have is I can't figure a way to get rid of superfluous commas when one is not called for at the end of the final string. Here are some examples, one that works fine I think, and then a couple that don't:
c:\java Sayb 10000500010
ten billion, five hundred thousand, ten
c:\java Sayb 1000
one thousand,
c:\java Sayb 147586000
one hundred forty-seven million, five hundred eighty-six thousand,
I'm not sure how much, if any, code I would want to post, but I think y'all have probably seen something like this before. Should I just wait to get the nit picked out of me? I'm just happy it works!!! (156 lines, including comments)
Thanks,
Jason Adam
Greg Harris
Ranch Hand

Joined: Apr 12, 2001
Posts: 1012
i am on my second attept at 4b. i used "-" between all of my numbers, though. they come out like one-hundred-billion-twenty-three. i do not know which one is right, so please tell me if anyone knows.
to get rid of the unused "," make something that will only print the "," if the next set of digits are not equal to "0"... in other words, instead of automatically appending the "," to your bigger number, do it only if neccesarry.


what?
Panday Manako
Ranch Hand

Joined: Mar 29, 2001
Posts: 80
i think nitpickers are not strict on comas. i didn't put comas in my numbers. i don't know about the "-".
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Greg '-' between every word is wrong.
Testing your example using the instructors solution gives one hundred billion, twenty-three
As for the commas yes, as far as I know they are not to strict on it. But if you submit the perfect solution, heck Marilyn might just decide to find something. Hard to say.
The general rule is give the assignment your best shot.Submit it and see what nitpick you get back. But remember dont waste the nitpickers time with rubbish that you for yourself know is not right.

[This message has been edited by Johannes de Jong (edited May 31, 2001).]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Hyphens should only be between the tens and the ones like: one thousand, one hundred twenty-three or one thousand one hundred twenty-three

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Greg Harris
Ranch Hand

Joined: Apr 12, 2001
Posts: 1012
oh, that was not clear in the instructions... and i did not get nitpicked for it on my first attempt! no big deal, though. i do not think it will take too much to change.
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Well, I first need to go back through 4a, lots of nits in there I need to get rid of, but I pretty much resigned myself to using the comma as a seperate string. Problem is I think I've already nested too many if/else if statements inside of each other that I'm going to be picked to pieces, but hey, what a great way to learn!
Thanks y'all,
Jason
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1195
Say 4b is a rite of passage. For myself, the commas and spacing were a matter of pride. I wanted those spaces and commas to behave themselves! It wasn't easy..........
Keep trying, you'll find a way!
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
Originally posted by Carol Murphy:
For myself, the commas and spacing were a matter of pride. I wanted those spaces and commas to behave themselves!

Thats the spirit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java 4b end commas