Basically I need to write a program in java that will ask the user for an integer, and then display that number vertically (using only math), so the number 2849 will display:
2
8
4
9
I know that I can use modulus by 10, getting 9, 4, 8, 2 but what I do not know is how to write code that will carry over the new value after the first modulus to keep going.
import java.util.Scanner;
public class HorizToVert {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a number: ");
int answer = input.nextInt();
System.out.print(answer%10);
}//close main
}//close class
That's what I have so far. As I said, I know that it will give me the first remainder. So say the user enters 4936. I know the first modulus gets me 6. I don't know how to go to 493 after I do that first modulus to continue the process. Any help would be great!