代码大致如下,供参考
public class ChouJiang{
public static void main(String[] args) {
int id = 8349;
int a = id/1000;
System.out.println(a);
int b = id%1000/100;
System.out.println(b);
int c = id%100/10;
System.out.println(c);
int d = id%10;
System.out.println(d);
int total =a+b+c+d;
if(total>20){
System.out.println("会员号"+id+"各位之和"+total+" 幸运用户");
}else{
System.out.println("会员号"+id+"各位之和"+total+" 谢谢惠顾");
}
}
}