Question: Write a program in java that displays a random permutation of the numbers 1 to 10. The resulting permutation is stored in an array of

Write a program in java that displays a random permutation of the numbers 1 to 10. The resulting permutation is stored in an array of integers. To generate a random permutation, you need Hint: Use two arrays: - One filled with the numbers in sequence 1-10 (this is your Array1) - Then create a second array (Array2) initialized with 0 that you fill replace with the 0-10 numbers of Array1 using the following algorithm: Generate a random number in the range 0-9 that you use to represent the index (position) in Array1. Copy the number found at that position in Array2. You must keep track of the values already entered in Array2 since duplicates are not permitted (this means that every time you try to enter a new number in Array2, you must traverse Array2 to check if the number is already present. If it is present you try again using a while loop. It it is not present, you append it to the values already entered. Repeat 10 times.

Try to design your program first using a pencil and paper!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!