Question: Complete java code and include comments explaining what's happening. thank you. int [] num_arr ={1,5,9,10,20,23,40,100}; Start by copying this array into the main( ) method

Complete java code and include comments explaining what's happening. thank you.
int [] num_arr ={1,5,9,10,20,23,40,100}; Start by copying this array into the main( ) method of your program, or typing in a similar one. Write a Java program that will 1) Print a message to the user to enter an integer number 2) Read the number the user will input 3) Search for the number in the array a. If found, print the array index at which it was found b. If not, print a message saying "Number not found" Notes: - Extra credit is described on the next page. - Your code should be general and it should work irrespective of the values in num_arr, not only the ones given here - Your program must use a loop to iterate through the array - Assume that the user input is correct. No error checking/error handling is required - If the input number appears more than once in the array, you can output the index of any of its occurrences in the array. - You are not required to write comments, but you are encouraged to do so. Comments can help us understand your code and give you partial credit, if needed. Extra credit: Assuming that num_arr is sorted, the loop should terminate once you find a match for the input number. In other words, don't iterate through the rest of the array, once a match is found. Sample output Enter a number: 20 Number not found Enter a number: 10 Number found at position 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
