import java.util.*; // given an integer up to 9999, sum the individual digits (e.g., 9999 = 9 + 9 + 9 + 9 = 36) public class Prog2_6 { public static void main(String[] args) { Scanner in = new Scanner(System.in); // keyboard input int number; System.out.print("Enter the number (0-9999): "); // prompt user for input number = in.nextInt(); int sum = number % 10; // initialize sum to rightmost digit number = number / 10; // remove this digit sum += number % 10; // add next digit to sum number = number / 10; // remove that digit sum += number % 10; // add next digit to sum number = number / 10; // remove that digit sum += number; System.out.println("The sum of the digits is " + sum); } }