Question: i have a code in java that does a binary search on a given array to determine if a user input number exist in the

i have a code in java that does a binary search on a given array to determine if a user input number exist in the given array. I must reprompt the user if the number is not in the array to enter another number to determine if it is in the array. This is where i have trouble:in the last part of the code I use a while loop to reprompt but when i run the program and test it still loops that the number is not in the array even though it is. how do i solve this with out for loops or another array

i have a code in java that does a binary search on

.I'm sure its something super simple i just dont get it. this is the last part of my code; the last else statement works, its just reprompt if statementand while above that doesn't. And i have already coded the binary search.

67 if (foundIndex== -1) { 68 69 70 while (foundIndex-=-1) { //int numberSearch2; System. out.print ("This number does not exist."); System.out.print (" Enter a number: ") 72 numberSearch-Integer.parseInt (keyboard.nextLine ()); 1) 74 75 1 6 else t System.out.println ("This numberl is valid."): 78 79 e0 e1 e2 83

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!