The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
LinearSearch
Write a Java program, called LinearSearch that contains a static method called findElement() that accepts a double array and a double as its parameters and return a boolean value if the double number entered is contained in the double array. In the main method you should use user input to take in the length of the array to be filled, then the elements of the array, and finally the element you wish to search for in the array. You program should call findElement() to check for the occurence of the double number entered in the array. You should print an appropriate message to the screen if the element is found.
Â
Input:
n mi mi+1 mi+2 .... mi+n x, where n is the length of the array, mi is an element in the array and x is the element that is being searched for.
Â
Sample input 1:
4.0 345.6 678.954 234.534 -89.23 678.954
Â
Sample input 2:
4.0 345.6 678.954 234.534 -89.23 67.4
Â
Output:
A message stating if the element is found.
Â
Sample output 1:
678.954 was found in the array
Â
Sample output 2 :
67.4 was NOT found in the array