Enter an integer: 1

Enter an integer: 3

Enter an integer: 2

Enter an integer: 1

Enter an integer: 5

Enter an integer: 4

Enter an integer: 5

Enter an integer: 2

Enter an integer: 4

Enter an integer: 5

The number of distinct values is 5

1 3 2 5 4

I understand the logic. I even researched using a set, but this would be outside the assignment and I wouldnt probably get credit. I'm just missing how to link Array1 to Array2 and how does this run all in one loop. Any help would be appareciated it.

import java.util.Scanner; /** * * @author Bear */ public class Exercise6_5 { public static void main(String[] args) { Scanner input = new Scanner(System.in); String output = ""; String output1 = ""; int[] numbers = new int[10]; int DistinctArray[] = new int[numbers.length]; int count = 0; for (int i = 0; i < numbers.length; i++) { System.out.print("Enter a number:"); // Conver String into integer numbers[i] = input.nextInt(); } for (int i = 0; i < numbers.length; i++) { int temp = numbers[i]; if (temp != numbers[i]) { output += numbers[i] + " "; } else DistinctArray[i] = temp - numbers[i]; output1 += DistinctArray[i] + " "; count++; System.out.println("The number of distinct values is: " + count); System.out.println("The array is: " + output); System.out.println("The test distinct array is: " + output1); } } }