SHARE
TWEET

Untitled

a guest Jul 17th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.*;
  2.  
  3. public class Lab2 {
  4.     public static void main(String[] args) {
  5.         Scanner s = new Scanner(System.in);
  6.         int n = s.nextInt();
  7.        
  8.         int sum = 0;
  9.         for (int i = 0; i < 4; i++) {
  10.             sum = sum + n % 10;
  11.             n = n / 10;
  12.         }
  13.        
  14.         System.out.println(sum);
  15.     }
  16. }
RAW Paste Data
Top