In: Computer Science
in Java, write a program that takes an input of 4 numbers and splits them into 4 separate lines.
EXAMPLE: so if input is 1994 the output should
be
1
9
9
4
import java.util.Scanner;
class splitnumber
{
public static void main(String []args)
{
Scanner in = new
Scanner(System.in);
int sn; // declaration
of split number
System.out.print("Enter
a four digit number:"); // Read number
int num = in.nextInt();
// take input from the user
while(num/10 == 0) //
loop runs until num value is zero
{
sn = num%10; // splits the number digit wise
System.out.println(sn); // here prints the digit
num = sn;
}
}
}