Information about applicants for a scholarship program is stored in Applicant objects.
public class Applicant
{
private String name;
private int score;
private boolean complete;
public Applicant(String n, int s, boolean c)
{
name = n;
score = s;
complete = c;
}
public String getName()
{
return name;
}
public int getScore()
{
return score;
}
public boolean isComplete()
{
return complete;
}
}
The ScholarshipGroup class stores a list of applicants.
public class ScholarshipGroup
{
private ArrayList<Applicant> applicants;
public ScholarshipGroup(ArrayList<Applicant> list)
{
applicants = list;
}
public ArrayList<String> finalists(int minScore)
{ /* to be written */ }
}
Write the method finalists, which returns a new ArrayList<String> containing the names of all applicants who satisfy both of the following conditions.
- The applicant's form is complete.
- The applicant's score is at least
minScore.
Among the applicants who satisfy those conditions, only applicants whose score is equal to the highest qualifying score should appear in the returned list. Names in the returned list must appear in the same order as the corresponding applicants appear in applicants. If no applicant qualifies, the method returns an empty list.
For example, if the qualifying applicants have scores 81, 94, 94, 88, the returned list should contain the names of the two applicants whose score is 94, in their original order.