Use the HashMap structure to map String to Integer, the String will be the route name, the Integer will be the number of students

HashMap supports methods put and get

You can use two passes to process get the answer.

On the first pass run over the list and put the value 0 against every route you encounter.

On the second pass use put to add 1 to each route you encounter.

It is better to use a single pass:

For each route if the key exists then +1 of the value, if the key does not exist then put 1.

.

[Font]
[Default]
[Show]
[Resize]
[History]
[Profile]

test text

Problem 5 – Use Map to count regions

Read in the file http://progzoo.net/bbc.txt and output a list of region and the number of countries in each.
This problem is just like the previous problem. If you use a TreeMap in place of a hash map then the output will be in order.

.

[Font]
[Default]
[Show]
[Resize]
[History]
[Profile]

test text

Problem 6 – Use Map to find associates

Read in the file bbc.txt and output a list of countries by region.
One way to do this is to build up a list of countries for each region. To do that you could use a structure such as: