Challenge problem

My code is failing second test case. Can anyone tell me why?

My code is:

import java.util.*;

public class Main {

static Scanner scn = new Scanner(System.in);
public static void main(String args[]) {
    int[] arr;
	arr = take_input();
	//System.out.println("What element do you want to search?");
	int ele = scn.nextInt();
	int index=binary_search(arr,ele);
	System.out.println(index);
}
public static int[] take_input() {
//	System.out.println("What size array do you want?");
	int n = scn.nextInt();
	int[] arr = new int[n];
	for (int i = 0; i < arr.length; i++) {
//		System.out.println("Enter value:");
		arr[i] = scn.nextInt();
	}
	return arr;
}
public static int binary_search(int[] arr,int num) {
	int index=-1,low=0,high=arr.length-1;
	int mid;
	//System.out.println(mid);
	while(low<=high) {
		mid=(low+high)/2;
		if(arr[mid]<num) {
			low=mid+1;
		}
		else if(arr[mid]>num) {
			high=mid-1;
		}
		else if(arr[mid]==num) {
			return mid;
		}
	}
	return index;
}

}

@VinayakSingh11111 bro i am checking it, meanwhile close all the previous doubts as the query is already resolved. mark them resolved.

@VinayakSingh11111 Have you read the question correctly, the sorted array was rotated its no more sorted so how are you applying binary search on the whole array?
You have to apply binary search. you should know that for binary search you are applying array should be fully sorted.

Here is the algo:-

  1. Find middle point mid = (l + h)/2
  2. If the key is present at the middle point, return mid.
  3. Else If arr[l…mid] is sorted
  a) If the key to be searched lies in the range from arr[l] to 
     arr[mid], recur for arr[l..mid].
  b) Else recur for arr[mid+1..r]
  1. Else (arr[mid+1…r] must be sorted)
  a) If the key to be searched lies in the range from arr[mid+1]
     to arr[r], recur for arr[mid+1..r].
  b) Else recur for arr[l..mid] 

You can check for this test case:-
7
5 6 7 1 2 3 4 6

your answer -1
but 6 is present

If your query is clear mark it resolved!