I\'m at a loss here.
I have this homework assignment where I have to enable the user to input 10 numbers, place them in an array, and figure out which inputted numbe
Instead of an array of input values, put them in a Set
of Integers
. Sets, by definition, store only unique values. If you add 3 'foos', there will be only one 'foo' in the set.
// Add this to your top-level loop
Set uniqueValues = new TreeSet;
uniqueValues.add(number);
// Add this after the loop to write all unique values on one line
for (Integer value : uniqueValues) {
System.out.print(value.toString() + " ");
}
// Now end the line.
System.out.println();