I need to 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. Enter a negative number to signify the end of the input. Assume that the maximum number of scores is 100.

import java.util.Scanner;
public class Test {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
double scores[] = new double[0];
double score, sum = 0, avg;
int i = 0;
while(true) {
System.out.print("Enter a new score or negative number to exit: ");
score = in.nextDouble();
if(score > 100)
System.out.println("Score cannot be greater than 100");
else if(score < 0)
break;
else {
double[] temp = new double[scores.length + 1];
System.arraycopy(scores, 0, temp, 0, scores.length);
scores = temp;
scores[i++] = score;
sum += score;
}
}
System.out.println("Total Scores entered: "+ i);
avg = sum / i;
System.out.println("Average score: "+ avg);
int aboveAvg = 0, belowAvg = 0;
for(i = 0; i < scores.length; i++) {
if(scores[i] >= avg)
aboveAvg++;
else
belowAvg++;
}
System.out.println("Number of scores above or equal to the average:" + aboveAvg);
System.out.println("Number of scores below the average:" + belowAvg);
}
}
![sterminated> Test [Java Application] C:AProgram FilesJavaljre1.8.0_40bin java Enter a new score or negative number to exit: 99.1 Enter a new score or negative number to exit: 85.6 Enter a new score or negative number to exit: -1 Total Scores entered: 2 Average score: 92.35 Number of scores above or equal to the average:1 f scores below the a verage 1](http://img.homeworklib.com/questions/faf13970-9a79-11eb-ac4f-5b4779cdd60d.png?x-oss-process=image/resize,w_560)
Please check the code. If you have any doubts comment below and I am happy to help :)
I need to write a program that reads an unspecified number of scores and determines how...
This is a Java program Write a program that reads an unspecified number of integers, determines home many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number to 2 decimal places. System.out.println(countPositive); System.out.println(countNegative); System.out.println(total); System.out.printf("%.2f",total * 1.0 / count); Assume inputs are always integer [-912985158, 912985158] and ends with 0. Input 1 2 -1 3...
Java programming 1. Write a program that reads an unspecified number of integers, determines how many positive and negative value have been read, and computes the total and average of the input values (not counting zeros. Your program ends with the input 0. Display the average as a floating point number Here are sample runs: (red indicates a user input) Enter an integer, the input ends if it is 0: 1 2 -1 3 0 The number of positives is...
(While-loop controlled by a sentinel value) Write a program that reads an unspecified number of integers. Your program ends with the input 0. Determine and display how many positive and negative values have been read, the maximum and minimum values, and the total and average of the input values (not counting the final 0).
(Statistics) a. Write a C++ program that reads a list of double-precision scores from the keyboard into an array named scores. It is assumed that the user will enter no more than 35 scores. The scores are to be counted as they're read, and entry is to be terminated when a negative value has been entered. After all scores have been input, your program should find and display the sum and average of the scores. The scores should then be...
(Count positive and negative numbers and compute the average of numbers) Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number. If you entire input is 0, display 'No numbers are entered except 0.' *So I think my code is looping because the...
Java Program 1. Write a class that reads in a group of test scores (positive integers from 1 to 100) from the keyboard. The main method of the class calls a few other methods to calculate the average of all the scores as well as the highest and lowest score. The number of scores is undetermined but there will be no more than 50. A negative value is used to end the input loop. import java.util.Scanner; public class GradeStat {...
Using basic c++ 2. Count the positive and negative numbers using ***while loop*** • Write a program that reads unspecified number of integers , determines how many negative and positive values have been read. Also calculate total and average. Your program will end with input 0. • Output Enter an integer, the input ends if it is 0: 25 34 -89 72 -35 -67 21 48 0 The number of positives is 5 The number of negatives is 3 The...
Write an application in java that reads in a five-digit integer and determines whether it is a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value. Tips: 1. Determine the number of digits in the value input by the user , i.e. prompt the user to enter the number of digits of the number. Use a while loop to determine whether the user input contains the proper...
Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...
Exercise 03: Write a program in java that read as input the scores of 3 quizzes of each student (out of 10 as follows) into a 2-D array: Enter the number of students> 4 Enter quiz scores for student 1> 10.0 2.04.0 Enter quiz scores for student 2> 5.5 6.0 6.0 Enter quiz scores for student 3» 8.259.04.0 Enter quiz scores for student 4> 9.5 8.5 2.0 The program then calculates the average of each quiz score for all the...