
Write an application that inputs one number consisting of five digits from the user.separates the number ibto its individual digits and prints the digits separated from one another by three spaces each.For Example.if the user types the number 42339,the program should print
4 2 3 3 9
Assume that the user enters the correct number of digits.What happens when you execute the program and type a number with more than five digits??What happens when you execute the program and type a number with fewer than five digits??

Java separate digits by space
import java.util.*;
class AddSpaceToDigits
{
public static String addSpaceToRight(String s, int n) {
return String.format("%1$-" + n + "s", s);
}
public static void main(String args[]) throws Exception {
Scanner input=new Scanner(System.in);
System.out.print("Enter number: ");
int num=input.nextInt();
String st=Integer.toString(num);
String digit[]=st.split("");
System.out.print(digit[0]);
for(int i=1;i<digit.length;i++){
System.out.print(addSpaceToRight(digit[i], 3));
}
System.out.println();
}
}

sry i dnt knw arrays yet...i want to solve this from any function...
42339/10000=4.2339take 4 from this
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.