summarize

Category: Arrays
Author: Brett Wortzman
Book Chapter: 7.2
Problem: summarize
Write a static method summarize that takes a single integer array parameter. The method should print out a summary of the array, describing sequences of repeated values as the number of occurrences and the value. The method should then return the number of such sequences that occurred in the array. The following table shows the behavior of summarize:

     int[] array1 = { 1, 2, 2, 3, 3, 3, 4, 4, 4, 4 };
     int[] array2 = { 5, 5, 5, 5, 5, 2, 2, 5, 5 };
     int[] array3 = { 1, 2, 1, 3, 1, 4 };
     int[] array4 = { 10, 11, 11, 10 };
     int[] array5 = { 7 };

     +-------------------+------------------------------------------+--------+
     | Call              |  Method Output                           | Return |
     +-------------------+------------------------------------------+--------+
     | summarize(array1) | 1 1's  2 2's  3 3's  4 4's               | 4      |
     +-------------------+------------------------------------------+--------+
     | summarize(array2) | 5 5's  2 2's  2 5's                      | 3      |
     +-------------------+------------------------------------------+--------+
     | summarize(array3) | 1 1's  1 2's  1 1's  1 3's  1 1's  1 4's | 6      |
     +-------------------+------------------------------------------+--------+
     | summarize(array4) | 1 10's  2 11's  1 10's                   | 3      |
     +-------------------+------------------------------------------+--------+
     | summarize(array5) | 1 7's                                    | 1      |
     +-------------------+------------------------------------------+--------+

You should reproduce this output format exactly. You may assume the array has at least one value, and you need not worry about singular or plural.