wood burning stoves 2.0*
The moose likes Cattle Drive and the fly likes Say 4b - the terror Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Say 4b - the terror" Watch "Say 4b - the terror" New topic
Author

Say 4b - the terror

Sam Tilley
Ranch Hand

Joined: Dec 05, 2001
Posts: 160
I notice doing a search on the Saloon that there seem to have been no recent postings on Say 4b and what a nightmare it can be. I got up to this tricky one relatively quickly but since then for the past 9 days have been struggling one way or another over the xmas period with it when i had time. It works (although still a bit long) up to 1 billion but i am having problems with the middle part and anything over 10 billion. I have tried parsing my input into a long variable and breaking it down to an int but still it is giving me some problems and telling me i have a number format exception.
I am trying to split down a number by
int numBill = (int) (input / anumber) although this still doesn't seem to work.
Can anyone give me a hint as to why it is not going as well as it should
Thanks
Sam

Sam Tilley SCJP, SCWCD
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1195
Say 4b is truly a test of endurance. If you try searching this forum you will find many posts on this very subject, and one of them may give you the very hint you need! Sorry, I'm too lazy to look up the links for you. Good luck!
Sam Tilley
Ranch Hand

Joined: Dec 05, 2001
Posts: 160
Thanks i have looked at quite a few old queries through the search and they have helped a lot.
But i just thought that a problem such as Say 4b deserved a recent thread in the hope of catching any passing chunks of wisdom that happened to float past and garner any newbies ideas / offer support to any others also removing clumps of hair.
Sam
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Originally posted by Sam Tilley:
I have tried parsing my input into a long variable and breaking it down to an int but still it is giving me some problems and telling me i have a number format exception.
I am trying to split down a number by
int numBill = (int) (input / anumber) although this still doesn't seem to work.

Seems like this should work if input is a long and anumber is an int.


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

Joined: Feb 06, 2001
Posts: 71
Sam,
You and I are new cowboys and we have to stick together. Here's a tip that really helped me ...
"I did a stint teaching English in Japan (haven't we all?). Our numbering system is significantly easier than theirs. To learn it, you only need to know how to count to 100 - after that, it's just 1-999 x, 1 - 999x, 1-999x,...1-9 and 99x. eg. 212,156,345 two hundred twelve MILLION, 1hundred fifty six THOUSAND, 3 hundred and forty five. The commas we use when writing numbers should be the clue everyone needs (I think). Perhaps a 2 dimensional array... (or would that be nitpicked?) I've got it working but have to wait for assignment 2 and 3 to be nitpicked first."
I forget the name of the person (sorry), but this got me on my way.

Good luck!!
PS Reconsider your love of "int"
Brad Ford
Ranch Hand

Joined: Mar 22, 2001
Posts: 40
That was me!
First time I've visited in many months - moved on to project management and haven't had much time/inclination to code in java these days - and there's a quote from me. Cool!
Anyhow, glad it helped
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Originally posted by Brad Ford:
haven't had much time/inclination to code in java these days

Blasphemy!!!
[ January 26, 2002: Message edited by: jason adam ]
Josue Cedeno
Ranch Hand

Joined: Feb 06, 2001
Posts: 71
Glad you like the quote, Brad. It was one of the best tips I could get!
Johannes de Jong
tumbleweed
Bartender

Joined: Jan 27, 2001
Posts: 5089
I think we should consider adding your tip/hint with the problem description of the assignment Brad. It might save quite a few questions here.
 
GeeCON Prague 2014
 
subject: Say 4b - the terror