(Analyzing scores) Write a program that reads an unspecified number of scores an
ID: 3655063 • Letter: #
Question
(Analyzing scores) Write a program that reads an unspecified number of scores and determines how many scores are above or equal to the average and how many scores are below the average. The program uses a dynamic array to keep track of the scores.Explanation / Answer
import java.util.Scanner; public class Exercise6_4 { public static void main(String[] args) { double[] scores = new double[10]; double sum = 0.0D; int count = 0; Scanner input = new Scanner(System.in); do { System.out.print("Enter a new score: "); scores[count] = input.nextDouble(); if (scores[count] >= 0.0D) sum += scores[count]; } while (scores[(count++)] >= 0.0D); System.out.println("count is " + count); double average = sum / (count - 1); int numOfAbove = 0; int numOfBelow = 0; for (int i = 0; i = average) numOfAbove++; else numOfBelow++; } System.out.println("Average is " + average); System.out.println("Number of scores above or equal to the average " + numOfAbove); System.out.println("Number of scores below the average " + numOfBelow); } }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.