import java.util.Scanner; public class BinarySearchProgram { public static void main(String[] args) { int[] items = {2, 3, 5, 7, 7, 12, 14, 19, 21, 24, 28, 32, 32, 45, 48, 49}; System.out.print("Enter the item that you are searching for: "); int searchItem = new Scanner(System.in).nextInt(); // Start searching from the beginning to the end of the array int start = 0; int end = items.length - 1; boolean found = false; // Keep going until the start index meets the end index, or unless we find it. while (!found && (start <= end)) { int middle = (start + end)/2; if (items[middle] == searchItem) found = true; else { if (items[middle] < searchItem) start = middle + 1; else end = middle - 1; } } if (found) System.out.println(searchItem + " is in the list."); else System.out.println(searchItem + " is not in the list."); } }