** * Write the method named examScore(). * * The "key" list contains the correct answers * to an exam, like ["a", "a", "b", "b"]. The "answers" * list contains a student's answers, with "?" representing * a question left blank. The two lists are not empty and * are the same length. Return the score for this list * of answers, giving +4 for each correct answer, -1 for * each incorrect answer, and +0 for each blank answer. * * Examples: * examScore(["a", "a", "b", "b"], ["a", "c", "b", "c"]) returns 6 * examScore(["a", "a", "b", "b"], ["a", "a", "b", "c"]) returns 11 * examScore(["a", "a", "b", "b"], ["a", "a", "b", "b"]) returns 16 * * @param key a list of correct answers to an exam. * @param answers the student's answers to the exam. * @return the score as described above. */ // TODO - Write the examScore method here. /** * Write the method filterBySize(). * * Given an ArrayList of String, return a new list where only * strings of the given length are retained. * * Examples: * filterBySize(["a", "bb", "b", "ccc"], 1) returns ["a", "b"] * filterBySize(["a", "bb", "b", "ccc"], 3) returns ["ccc"] * filterBySize(["a", "bb", "b", "ccc"], 4) returns [] * * @param list the list of Strings to process. * @param n the size of words to retain. * @return a new list of words with the indicated size retained. */ // TODO - Write the filterB
/**
* Write the method named examScore().
*
* The "key" list contains the correct answers
* to an exam, like ["a", "a", "b", "b"]. The "answers"
* list contains a student's answers, with "?" representing
* a question left blank. The two lists are not empty and
* are the same length. Return the score for this list
* of answers, giving +4 for each correct answer, -1 for
* each incorrect answer, and +0 for each blank answer.
*
* Examples:
* examScore(["a", "a", "b", "b"], ["a", "c", "b", "c"]) returns 6
* examScore(["a", "a", "b", "b"], ["a", "a", "b", "c"]) returns 11
* examScore(["a", "a", "b", "b"], ["a", "a", "b", "b"]) returns 16
*
* @param key a list of correct answers to an exam.
* @param answers the student's answers to the exam.
* @return the score as described above.
*/
// TODO - Write the examScore method here.
/**
* Write the method filterBySize().
*
* Given an ArrayList of String, return a new list where only
* strings of the given length are retained.
*
* Examples:
* filterBySize(["a", "bb", "b", "ccc"], 1) returns ["a", "b"]
* filterBySize(["a", "bb", "b", "ccc"], 3) returns ["ccc"]
* filterBySize(["a", "bb", "b", "ccc"], 4) returns []
*
* @param list the list of Strings to process.
* @param n the size of words to retain.
* @return a new list of words with the indicated size retained.
*/
// TODO - Write the filterBySize method here.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps