import java.util.Scanner;
public class binarys {
public static void main(String[] args)
{
Scanner reader = new Scanner(System.in);
int [] array = new int[10];
int search, index;
for (index=0;index<10;index++)
{
System.out.println("Enter numbers to array:");
array[index] = reader.nextInt();
}
System.out.println("Enter number to search:");
search = reader.nextInt();
int left = 0;
int right = array.length - 1;
while (left<=right)
{
int mid = (left+right)/2;
if (array[mid] == search)
{
System.out.println("The number is on index "+mid);
}
else if (array[mid] < search)
{
left = mid + 1;
System.out.println("The number is on index "+left);
}
if (array[mid] > search)
{
right = mid - 1;
System.out.println("The numer is on index "+right);
}
}
}
}