looking number in the array

PHOTO EMBED

Tue Jun 06 2023 21:37:28 GMT+0000 (Coordinated Universal Time)

Saved by @Mohamedshariif #java

public static void main(String[] args) {
		
		int[] array = {100,22,3,44,55,66,77,88};
		
		Scanner scanner = new Scanner(System.in);
		System.out.println("Enter number that you are looking for:");
		int number = scanner.nextInt();
		
		//int search;
		
		for(int i=0; i<array.length; i++) {
			if(number == array[i]) {
				System.out.printf("number %d is in the array it's index %d \n", number, i);
			}
			else {
				System.out.println("sorry");
			}
		}
		
		scanner.close();
	}
}
content_copyCOPY