Question
ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will be responsible for reading in the names and grades
ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION
THANK YOU
Write a program GS.java that will be responsible for reading in the names and grades for a group of students, then reporting some statistics about those grades. The statistics to be gathered are the number of scores entered, the highest score and the name(s) of the student(s) who earned that score, the lowest score and the name(s) of the student(s) who earned that score, and the average score for the class.
So if the names and scores are as follows:
Jake 76
Meghan 99
Liu 34
Alice 99
Joshua 25
program would print output: There were 5 scores, averaging 66.6.
The lowest score was 25 by Penny.
The highest score was 99 by Hermione and Linus.
INSTRUCTIONS: The program will need loops in two places: (i) to be able to read in data repeatedly, and (ii) to ensure that any erroneous input is detected and re-read until a valid input is obtained.
The program should read in names (single-word names are sufficient here) and scores until the name is entered as "done", at which time we stop reading names and scores and report the final statistics.
All scores should be in a valid range 0 to 100. If a score is entered outside of that range, your program should issue an appropriate message and re-read only the score (not the name, we already know that!) until a valid score is entered.
The program will need to keep track of a running total of the number of scores entered and the total number of points (to be used later to compute the average).
The program will need to keep track of the highest (and lowest) score seen so far and the name(s) of the students who earned that highest (and lowest) score.
Correct initialization of the variables you will use to keep track of high and low scores is essential to get this right. Note that the first score read in should become both the high and low score after the first time through the main loop. Think about how you can initialize those variables so that they will be set to the first score on the first loop iteration without treating that iteration as a special case (that is, the body of your loop does exactly the same thing on the first iteration as it will do on all subsequent iterations).
Note that if there is a tie (among any number of students) for the highest and/or lowest score, all students who tied the high or low should have their name included in the printouts at the end. Hint: think string concatenation.
If no valid names and scores are entered, a special message "You did not enter any scores!" should be printed rather than potentially erroneous stats.
Prompt for and read in both the name (which you may still assume consists of a single word) and score (which you may assume is an integer) in one step. That is, issue one prompt, then have two calls to your Scanner: one to read the name, the next to read the score. If the name is read as done, then do not attempt to read any score given on that line (nor report any error if no such score is present on the input).
Note that all comparisons of String values should use the equals method, and any comparisons of numeric values should use== and !=.
Define named constants to represent the highest possible score and the special name that is used to stop the loop. Those definitions should be the only places in the program where I see the int literal 100 or the String literal "done".
Remember to take the proper precautions when computing your average (which should be a double) from the scores (which are all ints). When you print your average, use a DecimalFormat object to make sure it prints with exactly one digit after the decimal point.
Step 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