Question: In Java Write a method countMajors(String filename) that reads the data in filename and returns a Map as described above. Feel free to use the

In Java

Write a method countMajors(String filename) that reads the data in filename and returns a Map as described above. Feel free to use the built-in Java map classes (java.util.HashMap, java.util.TreeMap) in your solution. You can assume that each line of the data file is formatted like this:

lastname,firstname,major

Heres an example of a situation thats well-suited for using the map data structure. Suppose you have a data file of students at a university, and youre trying to figure out how many students are in each major. You can read the file and parse the information into a map, where the keys are the majors and the values are the counts of how many students are in that major.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!