• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Say 4b - the terror

 
Sam Tilley
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Josue Cedeno
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad you like the quote, Brad. It was one of the best tips I could get!
 
Johannes de Jong
tumbleweed
Bartender
Posts: 5089
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic