RITIK
unknown
plain_text
a year ago
1.0 kB
3
Indexable
Never
import java.util.Scanner; public class NumberManipulation { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter a number: "); int number = scanner.nextInt(); scanner.close(); int evenCount = 0; int oddCount = 0; int originalNumber = number; while (number > 9) { int digitSum = 0; while (number != 0) { int digit = number % 10; if (digit % 2 == 0) { evenCount++; } else { oddCount++; } digitSum += digit; number /= 10; } number = digitSum; } System.out.println("Original number: " + originalNumber); System.out.println("Even count: " + evenCount); System.out.println("Odd count: " + oddCount); System.out.println("Single digit remaining: " + number); } }