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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started