Timur69

сумма

Apr 6th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Test10 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         System.out.println("Input number: ");
  7.         int i = scanner.nextInt();
  8.         int s = 0;
  9.         while (i != 0) {
  10.             s += i % 10;
  11.             i /= 10;
  12.         }
  13.         System.out.println(s + i);
  14.     }
  15. }
Add Comment
Please, Sign In to add comment