using arrays or Arraylist in java language
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.
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- First, implement a python class called Student. This class should store 2 variables, name and grade. Later, implement a class called Classroom. The constructor of this class should input the list of students in this classrom. This class should also contain 3 methods, add_student, remove_student and calculate_stats. As the names suggest, add_student method should input a Student object and add that to its' already existing student list, remove_student must input a full name(string) and delete the student with the provided name(you can assume no 2 students have the same full name). Finally, calculate_stats method must calculate and print the following statistics of the grades: 1. The name of the student with highest grade and the grade itself. 2. The name of the student with lowest grade and the grade itself. 3. The average gradearrow_forwardwrite a program that reads the students.txt file and stores the name of the student and the grade information as a student object in an arraylist sorts the students names based on their first grade in decreasing order using the selection sort algorithm writes the sorted list as the students last name , middle name (if theres one), first name , and grade information into a text file output example: Robison, Lee 95 80 Green, Alex R 85 60 Waston, Zoe G 100 80 use javaarrow_forwardWrite a public static method named allLessThanMean that will take an ArrayList<Integer> as an argument. This method will return an ArrayList<Integer>. When called and passed anArrayList, this method will return an ArrayList containing all the elements in the argument ArrayList that are less than the average of all the values in the argument ArrayList. The values in the returned ArrayList must be in the same order as they are in the argument ArrayList. Here are some examples: Example 1 Given: ArrayList<Integer> myList = new ArrayList<Integer>(); with these values {1, 2, 3, 4, 5}; allLessThanMean(myList) should return an ArrayList<Integer> with these values {1, 2} Example 2 Given: ArrayList<Integer> myList = new ArrayList<Integer>(); with these values {3, 7, 6, 2, 9, 0, 4, 8}; allLessThanMean(myList) should return an ArrayList<Integer> with these values {3, 2, 0, 4} Example 3 Given: ArrayList<Integer> myList = new…arrow_forward
- Define a collection “ArrayList” to store the students' names. Use a loop to take 5 students’ names from the user and store them in the collection. Add two student names to the collection and remove the last name in the list. Insert a student name in third place in the collection. Sort the names alphabetically. Ask the user to enter a student name and search for it in the collection and prints the result as “Found” or “Not Found”. Print the whole collection using the enhanced for loop. (java)arrow_forwardCreate an ArrayList of strings to store the names of celebrities or athletes. Add five names to the list. Process the list with a for loop and the get() method to display the names, one name per line. Pass the list to a void method. Inside the method, Insert another name at index 2 and remove the name at index 4. Use a foreach loop to display the arraylist again, all names on one line separated by asterisks. After the method call in main, create an iterator for the arraylist and use it to display the list one more time.arrow_forwardWrite a static method that displays all combinations of picking two numbers from the array list: public static void combinations(ArrayList<Integer> list) Include the driver program that prompts the user to enter 10 integers and displays all combinations of picking two numbers from the array list.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education