Question: Need help on Java H/W. Thanks This is Assignment 13 task 2 below the one I have compeleted. Here is the code for it below.

Need help on Java H/W. Thanks

Need help on Java H/W. Thanks This is Assignment 13 task 2

This is Assignment 13 task 2 below the one I have compeleted.

below the one I have compeleted. Here is the code for it

Here is the code for it below.

below. I will paste the code below to make it easier. import

I will paste the code below to make it easier.

import java.util.Random; import java.util.Scanner;

public class RandomArray { public static int search(int ar[], int key){

for(int i=0; i if(ar[i] == key)

return i; return -1; }

public static void main(String[] args) {

int arr[] = new int[1000];

Scanner sc = new Scanner(System.in); Random random = new Random();

for(int i=0; i

arr[i] = random.nextInt(100)+1; } System.out.print("Enter integer to be search: ");

int key = sc.nextInt(); int index = search(arr, key); if(index == -1){

System.out.println(key+" is not available in array");

}else{

System.out.println(key+" is available at location "+index); } } }

Programming Assignment: Update Assignment 13 Task 2 Create methods for each portion of the program. Create a method that will create an arrayL1000lthat will hold 1000 ntegers and between 1 1000 Create a method that will allow the user to input an integer and output the location if it exists in the Array or output number does not exist in the Arra Create an array that holds 1000 random integers between 1-1000 Allow the user to enter an integer to search output the location of number if it exists in the Array. (Number could appear more than once.) or Output number does not exist in the Array

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!