Hi Gurudas, I removed the solution to this problem because I don't think we should just post solutions to homework problems, it doesn't really help the OP, and it won't help other people searching the topic either.
Mike,
You get the error:
"Exception in thread "main" java.util.InputMismatchException: For input string: "12345"
at java.util.Scanner.nextInt(Scanner.java:2097)
at splitdigits.SplitDigits.main(SplitDigits.java:21)
The exception tells you at what line in your code the error happens:
"at splitdigits.SplitDigits.main(SplitDigits.java:21) "
If you look in your code line 21 will be this:
I looked up the Scanner API for the nextInt method:
Scanner#nextInt(int), and to paraphrase one of my favorite movies 'I do not think it does what you think it does.' The integer you pass in to nextInt is the 'radix', or the range of values for a single digit. When you pass in a radix of 5 you are saying each digit can hold a 0, 1, 2, 3, or 4 (one of 5 different values). You don't want to use that. You just want to use the normal nextInt method without the parameter:
You have some other compiler problems, noticeably next would be that your System.out.printf() statement is not correct. I will let you see if you can find the problem.