Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a generic method that implements a linear search in an array. This method should compare the search key with each element in an array

Write a generic method that implements a linear search in an array.  This method should compare the search key with each element in an array until the search key is found or until the end of the array is reached.  If the search key is found, return its location in the array; otherwise, return -1.  Write a test application that inputs and searches an int array and a double array.  The test application should have a GUI like this:

2- Linear Search Create integers Create doubles Enter Search Key Search

When the user clicks the “Create integers” button, the program generates 6 random integers between 0 and 999.  The user then enters a search key and presses the “Search” button.  The program will display the search result:

If the search key is not in the array, display “Value not found”:

if the “Create doubles” button is pressed, generate 6 random double values that have two digits after the decimal point between 0.00 and 99.99.  You can do this by generating 6 random integers between 0 and 999 and divide them by 100.  Do the same search as the integers.

 

Linear Search Create integers Create doubles Enter Search Key: Search

Step by Step Solution

3.48 Rating (164 Votes )

There are 3 Steps involved in it

Step: 1

import javautil class Solution public static void SearchE arrayE value generic met... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Document Format ( 2 attachments)

PDF file Icon
635de13f2c989_179648.pdf

180 KBs PDF File

Word file Icon
635de13f2c989_179648.docx

120 KBs Word File

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Programming questions

Question

Consider a M/G/1 system with E[S] Answered: 1 week ago

Answered: 1 week ago