How to seperate a number into its individual digits...

Hello,Can anyone give me the solution (or hints) to this simple exercise:Write an application that inputs one number consisting of five digits, seperates the number into its individual digits, and prints the digits seperated by three spaces each.thanks for any help
[293 byte] By [Lasiriusa] at [2007-10-3 2:20:10]
# 1

errr, dude... did you even think about this?

anyway, here is the simpliest version you can do. but since you didnt offer any detail, thats what you get.

you probably want to extend on this by:

- allowing user input via console or input box or something

- checking that the input is a number

- checking that the input is exactly 5 didgits in length

- dont add the spaces after the last didgit

public class SplitNumbers {

public static void main (String[] args) {

String input = args[0];

for (int i = 0; i < input.length(); i++) {

System.out.print(input.charAt(i) + "");

}

}

}

TimSparqa at 2007-7-14 19:19:04 > top of Java-index,Java Essentials,New To Java...
# 2
The above solution will work if the number is in String format. However if the number is an actual int then consider the results of (number % 10) and (number / 10).
floundera at 2007-7-14 19:19:04 > top of Java-index,Java Essentials,New To Java...
# 3
Thank you Flounder,That was what I was looking for. Ever read Deitel and Deitel Java How to Program? That was a probem I couldnt sort out from the text.
Lasiriusa at 2007-7-14 19:19:04 > top of Java-index,Java Essentials,New To Java...