忍不住试试
public class WanWan {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int []arr=new int[8];
int sum=0;
int max,min;
double av;
for (int j = 0; j < arr.length; j++) {
System.out.println("请输入整数:");
int t=sc.nextInt();
if (t>0) {
arr[j]=t;
max=arr[0];
min=arr[0];
sum+=t;
if (max<arr[j]) {
max=arr[j];
}
if (min>arr[j]) {
min=arr[j];
}
}else{
System.out.println("请输入正整数:");
j--;
continue;
}
if (j==7) {
System.out.println("最大:"+max);
System.out.println("最小:"+min);
av=sum*1.0/arr.length;
System.out.println("平均:"+av);
}
}
System.out.println("和:"+sum);
}
}