first commit

This commit is contained in:
Zakaria
2025-12-02 04:47:09 -05:00
commit 3e1d017ff2
12 changed files with 88 additions and 0 deletions
@@ -0,0 +1,31 @@
import java.util.Scanner;
/**
* SequentialSearch
*/
public class SequentialSearch {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("check the number x: ");
int input = sc.nextInt();
int[] arr = { 1, 3, 5, 6, 7, 21, 32, 42, 55, 66, 76, 83, 90 };
int position = 0;
boolean found = false;
while (position < arr.length && !found) {
if (arr[position] == input) {
found = true;
} else {
position = position + 1;
}
}
if (found) {
System.out.println(input + " found in position " + position);
} else {
System.out.println(input + " Not found in the array");
}
sc.close();
}
}