input a 3 digit number and print each digit in descending order

You seem to be making this a lot more complicated than it needs to be.

Scanner in = new Scanner(System.in);
int a = in.nextInt();
int p = a;
int r;
while (p > 0) {
    r = p % 10;
    System.out.print(r);
    p /= 10;
}

If the input is 214, then the above code will print 412.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top