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); } }
guozhchun
相关分类