In Out: Import Public Class Public Static Void Int New
In Out: Import Public Class Public Static Void Int New
In Out: Import Public Class Public Static Void Int New
Scanner;
public class find
{
public static void main(String args[])
{
int c, first, last, middle, n, find, array[];
Scanner in = new Scanner(System.in);
System.out.println("Enter number of elements");
n = in.nextInt();
array = new int[n];
int count = 0;
int count1 = 0;
System.out.println("Enter " + n + " integers");
int i = 0;
boolean found = false;
{
count1++;
System.out.println(find + " found at location " + (middle + 1) + ".");
System.out.println("The Binary find find found the number after " + count1 +
" comparisons.");
break;
}
else
last = middle - 1;
count1++;
middle = (first + last)/2;
}
if ( first > last )
{
System.out.println(find + " not found in the array.");
count1++;
}
}
}