I need to write a program that produces a single random permutation of the numbers 1 - 10. If possible, no methods or extra include libraries. Simple as can be. Here is what I have so far.
import java.util.Scanner;
public class SwitchingNum {
public static void main(String[] args) {
int num = 10;
Scanner in = new Scanner(System.in);
int[] tempArray = new int[10];
int currentSize = tempArray.length;
System.out.print("First Array: ");
for(int i = 0; i < num; i++){
tempArray[i] = i + 1;
System.out.print(tempArray[i] + " ");
}
int[] permArray = new int[tempArray.length];
System.out.println();
System.out.print("Second Array: ");
for (int i = 0; i < permArray.length; i ++){
permArray[i] = tempArray[(int) (Math.random() * currentSize -1)];
for (int j = i; j < currentSize -1; j++){
tempArray[i] = tempArray[i+1];
}
currentSize--;
System.out.print(permArray[i] + " ");
}
}
}