• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java 4b end commas

 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1012
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Panday Manako
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5089
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hyphens should only be between the tens and the ones like: one thousand, one hundred twenty-three or one thousand one hundred twenty-three
 
Greg Harris
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5089
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic