Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in Java that reads an unspecified number of scores and determine

ID: 3634519 • Letter: W

Question

Write a program in Java 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. Enter a negative number to signify the end of the input. Assume that the maximum number of scores is 10.

Explanation / Answer

import java.util.*; class count{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int input = 0; int count = 0; int sum = 0; double mean = 0.0; int bavg = 0; int aavg = 0; int[] array = new int[11]; System.out.print("Enter a number between 1 to 10: "); input = sc.nextInt(); while(input >=0){ sum += input; array[input]++; count ++; System.out.print("Enter a number between 1 to 10: "); input = sc.nextInt(); } mean = sum/count; for(int i =0; i = mean; i--){ aavg += array[i]; } System.out.println("number of score above or equal to average : "+aavg); System.out.println("number of score below average : "+bavg); } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote