Question: Create a Java Program that will drop the lowest n number of scores from an Array List of scores. If the number of scores to

Create a Java Program that will drop the lowest "n" number of scores from an Array List of scores. If the number of scores to be dropped is set to 0, then calculate the average of all the scores. If the number of scores to be dropped is > 0, then remove the lowest "n" amount of scores and calculate the average score from an Array List of scores.

This is an attached skeleton of a java class that can be used to create the program:

public class EnrolledStudent { private String fName; private String lName; private String id; private ArrayList scores; private Integer numScoresToDrop; public EnrolledStudent(String fName, String lName, String id, ArrayList scores) { this.fName = fName; this.lName = lName; this.id = id; this.scores = scores; } public String getfName() { return fName; } public void setfName(String fName) { this.fName = fName; } public String getlName() { return lName; } public void setlName(String lName) { this.lName = lName; } public String getId() { return id; } public void setId(String id) { this.id = id; } public ArrayList getScores() { return scores; } public void setScores(ArrayList scores) { this.scores = scores; } public Integer getNumScoresToDrop() { return numScoresToDrop; } public void setNumScoresToDrop(Integer numScoresToDrop) { this.numScoresToDrop = numScoresToDrop } public Double getGradePercent(){ Double aver = 0.0; Double sum = 0.0; for (Double score : scores){ sum += score; } aver = sum / scores.size(); System.out.printf(" FL1 - Aver:%s", aver); if(aver < 0 || aver > 100) { throw new IllegalArgumentException("Percentage must be between 0-100"); } return aver; } }

For example if the list of scores is: 90.0, 65.0, 70.0, 99.0, 80.0, and the number of lowest scores to drop is set to 1 (numScoresToDrop = 1). Then, the average would be 84.75 ((90 + 70 + 99 + 80) / 4).

If the number of lowest scores was set to 2, then the average would be: (90 + 99 + 80) / 3 = 89. 67

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!