Ex 7: Most Frequent Numbers

This exercise revisits SPA 2 which printed histograms. There are three big differences:

You are being given a starting point, main.cpp, with a lot of TODO entries guiding you to a solution. You can deviate from these suggestions as long as you are making good use of the STL and your solution produces correct output.

If you remember, the input to SPA 2 started with two numbers, a minimum and a maximum value. These were followed by a list of the data values. The program reported which data values did not fit in the range. At the same time, it built a table indicating how often each legal input appeared in the list of data values. Last, it formatted a chart showing how often each input appeared. For this assignment you will read the values, identify the five largest frequency counts, then print all of the data values (in numerical order) that occurred that many times. If there are fewer than five distinct frequency counts, you will print all of them.

As a simple example, if the input is

        9 13
        12 9 9 12 9 11 14
then the program prints
        Value 14 is out of range.
        Most frequent words:
        9: 3
        12: 2
        11: 1
because 9 appears three times, 12 twice, and 11 once. As a slight more complex example, the input
        0 4
        0 1 1 4 3 1 1 0
prints
        Most frequent words:
        1: 4
        0: 2
        3: 1
        4: 1
because both 3 and 4 appear just once. Note that if all of the values occur the same number of times - say, 9 - then all values will print since they all tie in frequencies.

The classes you will likely use in your solution:

Submission

Submit your version of main.cpp to esubmit. This will only be graded for your use of the STL and obtaining correct output - there will be no points for style issues. You are done when you submit your final version to esubmit as ex7stl