Question: Can you do the missing code. If you need more information please go to https://venus.cs.qc.cuny.edu/~mfried/cs313/hw/hw2.html for more info. import java.io.*; import java.util.*; public class HW2
Can you do the missing code. If you need more information please go to https://venus.cs.qc.cuny.edu/~mfried/cs313/hw/hw2.html for more info. import java.io.*; import java.util.*; public class HW2 { // Prints all movies that occur in both lists. public static void intersection(List list1, List list2) { // Fill in. } // Prints all movies in the list that occur at least k times // (print the movie followed by the number of occurrences in parentheses). public static void frequent(List list, int k) { // Fill in. } // Prints all movies in the list, grouped by year. // All movies from the same year should be printed on the same line. // Earlier years should be listed first. public static void groupByYear(List list) { // Fill in. } // Returns a List of all movies in the specified file (assume there is one movie per line). public static List getList(String filename) { List list = new ArrayList<>(); try (Scanner in = new Scanner(new FileReader(filename))) { while (in.hasNextLine()) { String line = in.nextLine(); list.add(line); } } catch (FileNotFoundException e) { e.printStackTrace(); } return list; } public static void main(String[] args) { List list1 = getList("1001_movies.txt"); List list2 = getList("rosenbaum.txt"); List list3 = getList("all_lists.txt"); List list4 = getList("sightsound_with_years.txt"); System.out.println("***intersection***"); intersection(list1, list2); System.out.println("***frequent***"); frequent(list3, 3); System.out.println("***groupByYear***"); groupByYear(list4); } } Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
