• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Java 4b end commas

 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 "-".
 
tumbleweed
Posts: 5089
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 5089
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic