with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Bin_Search; use Bin_Search; procedure Binary_Search_Test is -- Test driver for setting up array of values and calling a search routine. subtype List_Type is Integer_Array (1..10); ---------------------------------------------------------------------------- procedure Get_List (List : out List_Type; Count : out Natural) is -- Ask tester for list of values to put in search array. begin Put_Line ("Enter number of test elements (0-10)."); Get (Count); Put_Line ("Enter the test elements in order, one per line."); for Index in 1..Count loop Get (List(Index)); end loop; end Get_List; ------------------------------------------------------------------------------- Num_Elements : Natural; -- number of elements to search List : List_Type; -- list of elements to search Search_Value : Integer; -- value to search for in List Location : Natural; -- index of Value in List begin Get_List (List => List, Count => Num_Elements); Put ("Input value for which to search: "); Get (Search_Value); Binary_Search (List => List(1..Num_Elements), Value => Search_Value, Location => Location); if Location /= 0 then Put ("Search value found at location "); Put (Item => Location, Width => 2); else Put ("Search value not found in list"); end if; New_Line(2); end Binary_Search_Test;