Write a program that inputs a three-digit number from the user and displays it in reverse order. Fox example if the user enter 123, it display 321.

public static void main(String[] args) {

Scanner c= new Scanner(System.in);

int n,x,y;

System.err.println(“Enter 3 digit number”);

n=c.nextInt();

x=n/100;

n=n%100;

y=n/10;

n=n%10;

System.out.print(n);

System.out.print(y);

System.out.println(x);

}

}

Output

run:
Enter 3 digit number
678
876
BUILD SUCCESSFUL (total time: 3 seconds)

Leave a Reply

Your email address will not be published. Required fields are marked *