Question: Write a Java program that will use a one-dimensional array and perform the following operations in order: 1. Create a 1 - dim array (random

Write a Java program that will use a one-dimensional array and perform the following operations in order:

1. Create a 1 - dim array (random numbers, range 1-500, where 1and 500 should be declared as class constants).

2.Print the array.

3.Ask the user to input an integer value. Validate input (range 1 - 500)

4.Perform a linear search and print the appropriate message for key found/not found.

5. Sort the array in ascending order (use bubble sort).

6.Print the sorted array.

7.Ask the user to input an integer value. Validate input (range 1-500)

8.Perform a binary search and print the appropriate message for key

found/not found.

Use the following methods discussed in class:

1.Create a 1-dim array (random numbers, lower limit-upper limit)

2.Print a 1-dim array

3.Linear Search

4.Binary Search

5.Bubble SortGenerate output similar to the sample output below:

Start(Y/N)?y

The original list is:

196 408 14 292 255 106 96 95 82 64 439 432 2 392 182 160 449 88 40 70

Enter the search key for the unsorted list: 445

The key (445) was

NOT found!

The sorted list is:

2 14 40 64 70 82 88 95 96 106 160 182 196 255 292 392 408 432 439 449

Enter

the search key for the sorted list: 88

The key (88) was found in the element with index 6

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!