Input
Output
public class SumOfTwoDigits { public static void main(String[] args) { // Manually assigned two-digit number int number = 47; System.out.println("Enter a two-digit number: " + number); // Check if the number has exactly two digits if (number >= 10 && number <= 99) { int firstDigit = number / 10; // Get tens digit int secondDigit = number % 10; // Get ones digit int sum = firstDigit + secondDigit; System.out.println("Sum of digits = " + sum); } else { System.out.println("Please enter a valid two-digit number."); } } }