Question: import java.util.Scanner; public class ScoreAnalyzer { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print(How many scores to be entered?: ); int
import java.util.Scanner;
public class ScoreAnalyzer { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("How many scores to be entered?: "); int numScores = in.nextInt(); double[] scores = getScores(in, numScores); double average = findAverage(scores); int scoresAbove = countScoresAbove(scores, average); int scoresBelow = countScoresBelow(scores, average); System.out.println("The average is: " + average); System.out.println("Number of scores above or equal to the average: " + scoresAbove); System.out.println("Number of scores below the average: " + scoresBelow); }
public static double[] getScores(Scanner in, int numScores) { double[] scores = new double[numScores]; for (int i = 0; i 100) { System.out.println("Invalid. Enter a score: "); score = in.nextDouble(); } scores[i] = score; } return scores; }
public static double findAverage(double[] scores) { double sum = 0; for (int i = 0; i
public static int countScoresAbove(double[] scores, double average) { int count = 0; for (int i = 0; i = average) { count++; } } return count; }
public static int countScoresBelow(double[] scores, double average) { int count = 0; for (int i = 0; i
Here my code and here my result vs expected output. Please fix my code to match expected output, Thanks![import java.util.Scanner; public class ScoreAnalyzer { public static void main(String[] args) {](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2e7222d76f_91366f2e721cc5a4.jpg)

![int numScores = in.nextInt(); double[] scores = getScores(in, numScores); double average =](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2e72353a42_91566f2e72304715.jpg)

new score: Enter a new score: Enter a new score: The average is: 82.025 Enter a new score: Enter a new score: The average is: 74.83000000000001 Your output a new score: Enter a new score: Enter a new score: The average is: 74.0 Expected output r a new score: Enter a new score: The average is: 82.88000000000001 Your output or equal to the average: 3 the average: 2 a new score: Enter a new score: Enter a new score: The average is: 82.0 Expected output anewscore:Enteranewscore:Enteranewscore:Theaverageis:76.05 Your output anewscore:Enteranewscore:Enteranewscore:Theaverageis:75.0 Expected output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
