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
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 outputStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started