this is how i start then i couldn't figure out the rest..
public class Digits2 {
public static void main(String[] args) {
System.out.println("enter a three digit number ");
writ a program that ask a user to inter three integer number and type them to the screen and also print them in different lines .the out put should look like this one .
enter a three integer number:123
1
2
3
4 answers
so, the next step will be to accept use input. Check how to do that.
okay i used this function to print the out
Scanner in = new Scanner(System.in);
int num = in.nextInt();
but i don't know how to print each number in one line like this
1
2
3
Scanner in = new Scanner(System.in);
int num = in.nextInt();
but i don't know how to print each number in one line like this
1
2
3
you can do one of two things.
(1) use a pattern match to place the digits into an array, then print the array elements.
(2) convert the number to a string, then loop through the string, printing the 1st character and then removing it, till the string is empty.
(1) use a pattern match to place the digits into an array, then print the array elements.
(2) convert the number to a string, then loop through the string, printing the 1st character and then removing it, till the string is empty.