Question: Design and implement a Java method (name it getValues) in a separate class (name it DistinctValues). The method takes a single-dimensional array of integer values
Design and implement a Java method (name it getValues) in a separate class (name it DistinctValues). The method takes a single-dimensional array of integer values as a parameter and returns another single-dimensional array containing only distinct values in the original (passed) array.
Next, write a test program in a separate file (name it TestDistinctValues) such that the main method asks the user to enter 10 integer values into a single-dimensional array, then prints the ray before processing, then calls method getValues in class DistinctValues to extract distinct values into another array (which is returned to the caller), and then displays the outputs as shown below. Design the main method such that it allows the user to re-run the program with different sets of inputs (as in previous assignments, using a sentinel loop). Document your code, and organize and space the outputs properly using escape characters as shown in the following sample outputs:
Entered 10 integers: 5 2 1 5 2 3 2 1 5 9 Array before processing: 5 2 1 5 2 3 2 1 5 9 Array after processing: 5 2 1 3 9
Entered 10 integers: -5 21 2 0 2 -3 2 21 5 2 Array before processing: -5 21 2 0 2 -3 2 21 5 2 Array after processing: -5 21 2 0 -3 5
Entered 10 integers: 45 2 1 45 2 45 2 1 45 2 Array before processing: 45 2 1 45 2 45 2 1 45 2 Array after processing: 45 2 1
Entered 10 integers: 0 0 0 0 0 0 0 0 0 0 Array before processing: 0 0 0 0 0 0 0 0 0 0 Array after processing: 0
Entered 10 integers: 1 2 3 4 5 6 7 8 9 10 Array before processing: 1 2 3 4 5 6 7 8 9 10 Array after processing: 1 2 3 4 5 6 7 8 9 10
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
