Please complete in Java: Copy-paste option You are given a list of students name
ID: 3589397 • Letter: P
Question
Please complete in Java: Copy-paste option
You are given a list of students names and their test scores. Design an algorithm that does the following:
Calculates the average thest scores.
Determines and prints the names of all the students whose test score is below the average test score.
Determines the highest test score.
Prints the names of all the students whose texts score is the same as the highest test score. (You must divide this problem into subproblems as follows: The first subproblem determines the average test score. The second subproblem determines and prints the names of all the students whose test score is below the average test score. The third subproblem determines the highest test score. The fourth subproblem prints the names of all the students whose test score is the same as the highest test score. The main algorithum combines the solutions of the subproblems.)
Needs to be completed in Java
Explanation / Answer
StudentsGrades.java
import java.util.Scanner;
public class StudentsGrades {
public static void main(String[] args) {
// create a keyboard representing the scanner
Scanner console = new Scanner(System.in);
// define variables
double[] score = new double[10];
String[] name = new String[10];
double average = 0.0, highestScore = 0.0, sum = 0.0;
for (int i = 0; i < score.length; i++) {
System.out.print(" Enter the Name of student#" + (i + 1) + ":");
name[i] = console.next();
System.out.print("Enter the student's score: ");
score[i] = console.nextDouble();
sum += score[i];
} // end for loop
// calculate average
average = sum / score.length;
System.out.println("The average score is: " + average);
//Displaying the names of student names whose scores is less than average
System.out.println(" Displaying the Names of Students Less than Average :");
for (int i = 0; i < score.length; i++) {
if (score[i] < average)
System.out.println(name[i]);
}
highestScore = score[0];
for (int i = 0; i < score.length; i++) {
if (highestScore < score[i]) {
highestScore = score[i];
}
} // end for loop
//Displaying the students who got highest Scores
System.out.println(" Displaying the students who got highest Scores:");
for (int i = 0; i < score.length; i++) {
if (highestScore == score[i])
System.out.println(name[i]);
}
}
}
____________________
Output:
Enter the Name of student#1:James
Enter the student's score: 78
Enter the Name of student#2:Tom
Enter the student's score: 88
Enter the Name of student#3:Mike
Enter the student's score: 73
Enter the Name of student#4:Ken
Enter the student's score: 89
Enter the Name of student#5:Richard
Enter the student's score: 93
Enter the Name of student#6:Sachin
Enter the student's score: 65
Enter the Name of student#7:Ricky
Enter the student's score: 85
Enter the Name of student#8:Ben
Enter the student's score: 63
Enter the Name of student#9:Cook
Enter the student's score: 95
Enter the Name of student#10:Kenny
Enter the student's score: 56
The average score is: 78.5
Displaying the Names of Students Less than Average :
James
Mike
Sachin
Ben
Kenny
Displaying the students who got highest Scores:
Cook
_____________Could you rate me well.Plz .Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.