Activity 15.10.1.
Complete method
getScore below.
"?"). These answers are stored in an ArrayList in which the position of the answer corresponds to the question number on the test (question numbers start at 0). A student’s score on the test is computed by comparing the student’s answers with the corresponding answers in the answer key for the test. One point is awarded for each correct answer and 1/4 of a point is deducted for each incorrect answer. Omitted answers (indicated by "?") do not change the student’s score.
public class StudentAnswerSheet
{
private List<String> answers;
/** @param key the list of correct answers, represented as strings
* of length one
* Precondition: key.size() is equal to the number of answers in
* this answer sheet
* @return this student's test score
public double getScore(List<String> key)
{
/* to be implemented in part (a) */
}
/** @return the name of the student
*/
public String getName()
{
/* implementation not shown */
}
// There may be other fields, constructors, and methods
}

StudentAnswerSheet method getScore. The parameter passed to method getScore is a List of strings representing the correct answer key for the test being scored. The method computes and returns a double that represents the score for the student’s test answers when compared with the answer key. One point is awarded for each correct answer and 1/4 of a point is deducted for each incorrect answer. Omitted answers (indicated by "?") do not change the student’s score.
getScore method.
getScore below.
getScore below.
public class TestResults {
private List<StudentAnswerSheet> sheets;
/**
* Precondition: sheets.size() > 0; all answer sheets in sheets have the same number of answers
*
* @param key the list of correct answers represented as strings of length one Precondition:
* key.size() is equal to the number of answers in each of the answer sheets in sheets
* @return the name of the student with the highest score
*/
public String highestScoringStudent(List<String> key) {
/* to be implemented in part (b) */
}
// There may be fields, constructors, and methods that are not shown.
}
TestResults method highestScoringStudent, which returns the name of the student who received the highest score on the test represented by the parameter key. If there is more than one student with the highest score, the name of any one of these highest-scoring students may be returned. You may assume that the size of each answer sheet represented in sheets is equal to the size of key.
highestScoringStudent below.
highestScoringStudent method.
highestScoringStudent below.