package com.sf._03_collections;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Test1 {
    /**
     * List<Double> 存储评委打分的分数
     *
     * Scanner 在控制台进行键盘录入  录入5个分数
     *
     * 去掉最大值 和最小值
     * 求平均分就是这个选手最终得分
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Double> list = new ArrayList<>();
        for (int i = 0; i <= 4; i++) {
            System.out.println("请第"+ (i+1)+"评委打分");
            double score = scanner.nextDouble();
            list.add(score);
        }
        // 求最低分
        Double minScore = Collections.min(list);
        // 求最高分
        Double maxScore = Collections.max(list);

        list.remove(minScore);
        list.remove(maxScore);

        Double totalScore = 0.0;
        for (Double aDouble : list) {
            totalScore += aDouble;
        }
        System.out.println("评分为:"+ totalScore/list.size());
    }
}
