Adblock breaks this site

Need Some Help

Discussion in 'Programming General' started by wtp, Mar 29, 2011.

  1. wtp

    wtp Grand Master
    Banned

    Joined:
    Nov 25, 2005
    Posts:
    2,455
    Referrals:
    2
    Sythe Gold:
    0
    Need Some Help

    Hey guys. I'm trying to do a programming lab for school.

    [​IMG]

    How do I separate a number like 3456 to 3 4 5 and 6? I looked everywhere, but I can't find the answer, it's probably very simple.
     
  2. The Black Tux

    The Black Tux Veteran
    The Black Tux Donor Java Programmers PHP Programmers

    Joined:
    Apr 19, 2009
    Posts:
    10,306
    Referrals:
    30
    Sythe Gold:
    55
    Vouch Thread:
    Click Here
    Two Factor Authentication User Cool Kid Former OMM Cook RsProd Sythe Awards 2012 Winner Village Drunk
    Need Some Help

    divide string into char array, create new string, for each char do space...
     
  3. wtp

    wtp Grand Master
    Banned

    Joined:
    Nov 25, 2005
    Posts:
    2,455
    Referrals:
    2
    Sythe Gold:
    0
    Need Some Help

    Which code would I use to create an array?
     
  4. AleZ

    AleZ Member
    Banned

    Joined:
    Mar 2, 2011
    Posts:
    89
    Referrals:
    0
    Sythe Gold:
    0
    Need Some Help

    You can use the regex split() and Integer valueOf() along with the scanner.

    scan for input (input example: 1 2 3 4)
    String numbers[] = input.split(" ");
    convert to int using valueOf
    add ints together to get sum.

    Have fun!
     
< NEED Help making a Bot. | Trouble developing a User Control - HELP! >


 
 
Adblock breaks this site