import java.util.Scanner;
public class Ex5_2 {
public static int sumDIgits(long n){ int tmp;
int result = 0;
Long m = new Long(n);
while(n>0){
tmp = m.intValue();
result = tmp%10 +result;
tmp = tmp/10;
}
return result;
}
public static void main(String[] args) {
System.out.println("Please Input a long number:");
Scanner sc = new Scanner(System.in);
Ex5_2 ex = new Ex5_2();
System.out.println(ex.sumDIgits(sc.nextLong()));
}
}
互换的青春
料青山看我应如是
POPMUISE