Results 1 to 3 of 3
  1. #1
    cshoya is offline Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    Default Splitting number

    Hello,

    I am currently trying to figure out a way to create a number checker and one of the steps involves splitting up a number into it's separate digits. Here is an example of what I'm trying to do:

    given the number 56197245 take every other digit starting with the 5 on the left and double it. So that would give you 10, 2, 14, 8. You then have to add up all the digits involved so you would have 1+0+2+1+4+8.

    Any advice?

    Thanks

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    You can do a few things, one is to turn it to a String, and use the string to extract each individual number, or you can use % and / to split the number up.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,576
    Rep Power
    23

Similar Threads

  1. Splitting Strings
    By punk in forum New To Java
    Replies: 3
    Last Post: 04-06-2011, 08:49 AM
  2. Problem splitting a string
    By sehudson in forum New To Java
    Replies: 2
    Last Post: 03-13-2011, 08:56 PM
  3. Splitting
    By marksey07 in forum New To Java
    Replies: 2
    Last Post: 01-05-2011, 01:55 AM
  4. String Splitting
    By A.M.S in forum New To Java
    Replies: 1
    Last Post: 12-04-2009, 07:17 AM
  5. Array splitting
    By Lunarion in forum New To Java
    Replies: 3
    Last Post: 04-17-2009, 08:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •