/* * Prints the digits of an integer in a reverse order. * Suggested exercises: * - Compute the sum of the digits of an integer. * - Use nested loops to prove experimentally that * if the sum of the digits of a number is 9, * then the number is multiple of 9 (what about the inverse?). */ import java.util.Scanner; class PrintDigits { public static void main (String[] args) { Scanner scan = new Scanner(System.in); System.out.print ("Type an integer: "); int n = scan.nextInt(); while (n > 0) { System.out.print(n % 10); n = n/10; } System.out.println(); } }