测试数据包括多个实例。 每组数据包括7个实数,代表评委们对该选手的评分。紧接着是选手的名字,名字的长度不超过30个字符。 输入直到文件结束。
算出每位选手名字和最终得分,结果保留两位有效数字(四舍五入)。
10 10 10 10 10 10 9 redraiment 0 0 0 0 0 0 0 beast
redraiment 10.00 beast 0.00
import java.text.DecimalFormat; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { double max = 0; double min = 100; double sum = 0; for (int i = 0; i < 7; i ++ ) { double a = sc.nextDouble(); sum += a; min = min < a ? min : a; max = max > a ? max : a; } String name = sc.next(); System.out.println(name + " " + new DecimalFormat("#0.00").format((sum - min - max) / 5)); } } }