i have to create a DigitsDisplay application that prompts the user for a non negative integer and then displays each digit on a separate line like such
"Enter a positive integer: 789
7
8
9
this is what i have so far
Can someone please help me fix this program ?
im very new to java
import java.util.Scanner
public class DigitsDisplay
{
public static void main(String[] args)
{
int maxVal = 10000000;
int userInput;
Scanner input = new Scanner (System.in);
System.out.print("Enter a positive integer: ");
userInput= input.nextInt();
while (maxVal > userInput) {
maxVal = maxVal/10;
}
int value1 = userInput % maxVal;
System.out.print(userInput/maxVal);
}
}