Write a method named mostUnique
that accepts as its parameter a Scanner
for an input file.
The data in the file represents integer quiz scores separated by spaces.
Each class period is on its own line and contains a different number of students.
Your method should return the highest number of unique scores given in a single class period.
The method should also print information about the number of unique scores given in each period, in a format described below.
On a given line, all occurrences of any particular number value will occur consecutively in the input.
For example, if there is a sequence of occurrences of the number 8, there will not be any other occurrences of the number 8 on that same line outside of that sequence.
Given a Scanner
named input
referring to an input file that contains the following text:
10 10 10 9 9 8 3
3 3 8 10 9 7 7 6 6
4 1 9 9 10 7 7
10 10 10 10
The call on mostUnique(input)
should return 6
and generate the following output:
Period 1: 4 unique scores
Period 2: 6 unique scores
Period 3: 5 unique scores
Period 4: 1 unique scores
On the first line, there are 4 unique scores: 10, 9, 8 and 3.
The second line contains 6 unique scores: 3, 8, 10, 9, 7 and 6.
The third line contains 5 unique scores: 4, 1, 9, 10 and 7.
The fourth line only has one unique score: 10.
The value returned is 6 because it is the highest number of unique scores given in a class period.
Assume that the file exists, that it contains at least one line of data and that each line contains at least one score.