The user will input a three digit number
if they input 678 I need to output 876

I have 8 and 6 but I can't get 7

help me


/* Unit 1 - Lesson 5 - Coding Activity Question 1 */

import java.util.Scanner;

class U1_L5_Activity_One {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Please enter a two digit number: ");
int x = scan.nextInt();
System.out.println("Here are the digits:");
System.out.println(x/100);
System.out.println(x/10);
System.out.println(x%10);


}
}

Respuesta :

import java.util.Scanner;

public class U1_L5_Activity_One {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.print("Please enter a two digit number: ");

int x = scan.nextInt();

System.out.println("Here are the digits:");

System.out.println(x/100);

System.out.println((x/10)%10); //Just divide the result by 10 and find the remainder

System.out.println(x%10);  

}

}

//Or, you can do that way:

import java.util.Scanner;

 

public class U1_L5_Activity_One {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.print("Please enter a two digit number: ");

String[] x = scan.nextLine().split(""); //We need it to be a string array, to split the values after "", that is, after each symbol(number)

System.out.println("Here are the digits:");

for(int i = 0; i<x.length; i++) {

          System.out.println(Integer.parseInt(x[i])); //Converting the string into int, as you want

      }  

}

}