So I have written the following program with methods: inputArray, selectionSort, binarySearch, and printArray. I am currently working on the main method and am struggling with what to do.
"Write the main method to invoke inputArray, selectionSort, and printArray methods. Next, your main method should ask the user to input a double value to use as a search key and then invoke the binarySearch method. Finally, the main method should print out the location of the key if it is in the list and an appropriate message if the key is not in the list."
How can I print the the index value from the binary search?
You need to use the return value of the binary search method:
if (binarySearch(array1, key) < 0) {
// key is not in the array
} else {
// key is in the array
}