Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement