代码如下:
public class Task07 {
public static void main(String[] args) {
// 声明部分
double[] scores = new double[10]; // 双精度一维数组,10个元素,scores[0], scores[1],..., scores[9]
double sum, average, max, min;
Scanner sc = new Scanner(System.in);
// 输入部分
for (int i = 0; i < scores.length; i++) {
System.out.print("scores[" + i + "] = ");
scores[i] = sc.nextDouble();
}
// 处理部分
sum = 0;
for (int i = 0; i < scores.length; i++) {
sum = sum + scores[i];
}
average = sum / scores.length;
max = Double.MIN_VALUE;
for (int i = 0; i < scores.length; i++) {
if (scores[i] > max) {
max = scores[i];
}
}
min = Double.MAX_VALUE;
for (int i = 0; i
版权声明:本文为qq_67308027原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。