This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Splitig integers

 
Iain Palmer
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing the program say and am wondering how to split an integer into 2 separate numbers, I'm sure it simple but I can't think of how to do it? I had thought about not spliting the integer and just ahving a very big switch statment but thought there must be a better way
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use / and %
 
Iain Palmer
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so say i input 37 i divide by 30 which leaves me 7
 
Horatio Westock
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When you say 'split an integer', what exactly to you mean?

Do you have a practical example to help us understand?

Thanks.
 
Iain Palmer
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing the program for the assignment Java-4(Say) in the Cattle Drive and when a number is input into the program say 57. I want to be able to arrange the numbers so I can get the fifty and output that then add the seven onto it separatly
 
Iain Palmer
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got it working from numbers 1-10 & 20-99 but am now having trouble witt numbers 11-19
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic