1 import java.util.Scanner;
2 public class ArithMetic {
3 public static void main(String[] args) {
4 calcArr();
5 }
6 public static void calcArr()
7 {
8 int[] arr = new int[10];
9 int max = Integer.MAX_VALUE;
10 int min = Integer.MIN_VALUE;
11 int total = 0;
12 int avg = 0;
13 Scanner scan = new Scanner(System.in);
14 for (int i = 0; i < arr.length; i++) {
15 String s = "a";
16 while(!s.matches("^[0-9]+$"))
17 {
18 //System.out.printf("请输入第%d个数%n", i+1);
19 System.out.println(String.format("输入第%d个数", i+1));
20 s = scan.next();
21 }
22 arr[i] = Integer.parseInt(s);
23 if(max < arr[i])
24 max = arr[i];
25 if(min > arr[i])
26 min = arr[i];
27 total += arr[i];
28 }
29 System.out.println("最小值:"+min);
30 System.out.println("最大值:"+max);
31 System.out.println("平均值:"+total/arr.length);
32 }
33 }