I am new to Java and trying to do the following:
Given an integer array, if an integer in the array is between 70 and 79, print "Yes". Otherwise, print "no".
Here is my code so far:
import java.util.Arrays;
int temperatures[] = {45, 70, 71, 67}; //create array
Arrays.sort(temperatures); //sort temperatures
int key = 70; //define key to be searched
int result = Arrays.binarySearch(temperatures,key);
I know this will find me the 70 value that's in the temperatures array, but what's the best way to use binarySearch to see if ANY value in the 70s is in the array?