| 1 | import java.util.Scanner; |
| 2 | |
| 3 | public class CountDigits { |
| 4 | public static void main(String[] args) { |
| 5 | Scanner sc = new Scanner(System.in); |
| 6 | int n = sc.nextInt(); |
| 7 | int sumOfDigits = 0; |
| 8 | int original_n = n; |
| 9 | |
| 10 | while(n > 0) { |
| 11 | sumOfDigits += n % 10; |
| 12 | n = n / 10; |
| 13 | } |
| 14 | |
| 15 | System.out.println("Sum of digits in " + original_n + " = " + sumOfDigits); |
| 16 | } |
| 17 | } |
nothing calls this directly
no outgoing calls
no test coverage detected