打卡
Topic sourcepublic class DuoweiArray {
public static void main(String[] args) {
int[][] scores = {
{82,90,91},
{68,72,64},
{95,91,89},
{67,52,60},
{79,81,85}
};
int sum = 0;
int length = 0;
double average = 0;
for (int[] stu : scores){
for (int stuscore : stu){
sum += stuscore;
length++;
}
}
System.out.println(sum);
System.out.println(length);
average = (double) sum/length; //类型必须为double,如果是float,就通不过测试了
System.out.println(average);
if (Math.abs(average-77.733333) < 0.000001){
System.out.println("测试成功");
}else{
System.out.println("测试失败");
}
}
}
- 1
lookphp