C# Window Application: Write a generic method that implements a linear search in
ID: 3684429 • Letter: C
Question
C# Window Application:
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:
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.
2- Linear Search Create integers Create doubles Enter Search Key SearchExplanation / Answer
linear search algorithm we can implement using java windows with buttons. procedure linear_search (list, value) for each item in the list if match item == value return the item's location end if end for end procedure import java.util.Scanner; class LinearSearch { public static void main(String args[]) { int c, n, search, array[]; Scanner in = new Scanner(System.in); System.out.println("Enter number of elements"); n = in.nextInt(); array = new int[n]; System.out.println("Enter " + n + " integers"); for (c = 0; cRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.