import java.util.*;
public class Test7_4 {
public static void main(String[] args) {
int[] scores = new int[scores.length];
Scanner input = new Scanner(System.in);
System.out.print("Enter scores: ");
for (int i = 0; i < scores.length; i++) {
//int a = input.nextInt();
if (input.nextInt() > 100)
continue;
if (input.nextInt() < 0)
break;
scores[i] = input.nextInt();
}
for (int i = 0; i < scores.length; i++) {
printCount(scores);
}
public static void printCount(int[] scores)
{
if (scores.length == 0)
{
System.out.println("No argument passed!");
return;
}
int sum = 0;
for (int i = 0; i < scores.length; i++) {
sum += scores[i];
}
double avg = sum / scores.length;
int countUp = 0;
int countLow = 0;
for (int i = 0; i < scores.length; i++) {
System.out.println(scores[i] + " ");
if (scores[i] >= avg)
countUp++;
else
countLow++;
}
System.out.printf("The avg is %3.1f\nUp count is %2d\nLow count is %2d\n", avg, countUp, countLow);
}
}
1 回答
已采纳
guozhchun
TA贡献103条经验 获得超76个赞
for (int i = 0; i < scores.length; i++) { printCount(scores);
这里少打了一个'}',或者把 '{' 去掉
添加回答
举报
0/150
提交
取消