Question
///Java: Write a program to get create, sort, print, and searches an array containing random numbers of random numbers. ? Declare an array of size
///Java: Write a program to get create, sort, print, and searches an array containing random numbers of random numbers.
? Declare an array of size 10. (an unsorted array) ? Fill each element in this array with random numbers from 1 to 20. ? Make a copy of this array. (to be sorted) ? Using the java API, sort the copy. ? Print a table showing both the unsorted and sorted arrays as shown in the sample below. ? Enter a number to search for. ? Utilizing a for each loop: ? Search for the search string in both the unsorted and sorted arrays. o Output the search value and location found as shown in the example or output the search value was not found.
//output sample.
///////////////////////////////////////////////////////////////////////////
Code I have come up with but does not seem to work.
import java.util.Scanner; import java.util.Random; import java.util.Arrays;
public class ArrayWork { public static void main(String[] args) { Scanner scan = new Scanner(System.in); Random rand = new Random(); int array1 = new int[10]; // array size of 10 int array2 = new int[array1.length]; // copy of array1 int search = scan.nextInt; // user input number to search for int ele1 = 0; // element in array1 int ele2 = 0; // element in array2 int temp = 0; // temporary holder for (int i = 0; i
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