Hi, im writing an application in java that collects a number consisting of 5 digits,for example, 11234 from the user. The problem i have is that i want to separate the individual digits and display them separated by 3 spaces. thank you in advance for your help.

Hi, im writing an application in java that collects a number consisting of 5 digits,for example, 11234 from the user. The problem i have is that i want to separate the individual digits and display them separated by 3 spaces. thank you in advance for your help.

You can use the / and % operators to isolate each digit. You should probably set up an array of five integers to hold the digits and set up a for-loop. Isolate one digit every trip through the for-loop.

Puk, You are lazy.

int n=12345;

        String s="";

        while(n>0)
           {
             s=n%10 + "   " + s;
             n=n/10;
           }

        System.out.println(s);
This question has already been answered. Start a new discussion instead.