In: Computer Science
in .java
Write a program that reads an integer with 3 digits and prints each digit per line in reverse order. Hint: consider what you get from these operations: 319%10, 319/10, 31%10, ...
Enter an integer of exactly 3 digits(e.g. 538): 319 9 1 3
Hint: consider what you get from these operations: 319%10 319/10 31%10
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
System.out.print("Enter an integer
of exactly 3 digits(e.g. 538): ");
Scanner sc=new
Scanner(System.in);
int n=sc.nextInt();
while(n>0)
{
int r=n%10;
System.out.println(r);
n=n/10;
}
}
}