import java.util.Scanner;
public class PingWei {
public static void main(String[] args) {
//题目:定义动态数组,完成6个评委打分
double pingwei[] = new double[6]; //定义6个数组
Scanner scanner = new Scanner(System.in);
for (int i = 0; i <pingwei.length; i++) { //遍历数组每个位置,让用户输入6个评委的分数
System.out.println("请输入第"+ (i+1) +"位的评分");
double dou = scanner.nextDouble();
pingwei[i]= dou; //将用户输入的6个数存入到数组中去
}
double zonghe = 0;
for (int i = 0; i < pingwei.length; i++) { //遍历数组每个元素
zonghe +=pingwei[i]; //对每个元素进行求和
}
System.out.println("评委输入的总平均分为:"+ zonghe/pingwei.length);
标签:数组,double,System,pingwei,评委,zonghe,打分 From: https://www.cnblogs.com/nulicheng/p/17844529.html
}
}