public class Homework07 {
void test2 (int a){
int t,x=0,i;
for(i=1;i<=4;i++){
t=a%10;
a=a/10;
x=x+t;
}
System.out.println("四位数的各位数和为"+x);
}
}
import java.util.Scanner;
public class Main07 {
public static void main(String[] args){
Homework07 y = new Homework07();
Scanner s = new Scanner(System.in);
System.out.println("a=");
int a=s.nextInt();
y.test2(a);
}
}