Write a static method called printSum that takes an
integer n and integers low and high as parameters and that produces a series
of n integers between low and high inclusive, printing various information
about the integers. The method should construct and use a Random object to
generate the numbers. For example, if you make the following call:
printSum(15, 4, 8);
the method should produce three lines of output like the following:
sum 15 numbers 4 to 8
6 + 6 + 4 + 6 + 6 + 8 + 8 + 7 + 8 + 4 + 8 + 7 + 6 + 6 + 8 = 98
max = 98
The first line indicates that the method is going to find the sum of 15
numbers between 4 and 8 inclusive (as indicated by the parameters in the
call). The second line shows the 15 numbers randomly selected by the method
and their sum. The third line reports the highest partial sum for the
series. A partial sum is the value obtained by adding up a limited number
of terms (in the example above, a sum of 6 for one term, a sum of 12 for two
terms, a sum of 16 for three terms, and so on). In this case, the maximum
sum is the overall sum, but that won't always be the case. For example, if
the call instead had been:
printSum(10, -2, 2);
the output would look like the following:
sum 10 numbers -2 to 2
-1 + 2 + 2 + 2 + -1 + -1 + -2 + 2 + 0 + -1 = 2
max = 5
Here the maximum sum occurs with the first four numbers that add up to 5.
You are to exactly reproduce the format of these logs. You may assume that
n is greater than or equal to 1 and that low is less than or equal to high.