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

BIN
.DS_Store vendored Normal file

Binary file not shown.

BIN
D197_Version_Control/.DS_Store vendored Normal file

Binary file not shown.

@ -0,0 +1 @@
Subproject commit 287d3674869b7c6f2367e8df14243ee8e52663fb

@ -0,0 +1 @@
Subproject commit 6d582531fc4696513f82e83e9f3cf08cc08f5308

View File

@ -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();
}
}

View File

@ -0,0 +1,26 @@
/**
* SequentialSearchSortedarray
*/
public class SequentialSearchSortedarray {
public static void main(String[] args) {
int[] sortedArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int index = SeqSearch(sortedArray, 53);
if (index != -1) {
System.out.println("Element found at index " + index);
} else {
System.out.println("Element not found");
}
}
public static int SeqSearch(int[] arr, int value) {
for (int i = 0; i < arr.length; i++) {
if (arr[i] == value) {
return i;
}
}
return -1;
}
}

View File

@ -0,0 +1,27 @@
import java.util.Scanner;
/**
* Squareroot
*/
public class Squareroot {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("enter your guess");
double square = sc.nextDouble();
// initial the difference
double epsilon = 1;
// initial guess
double guess = square / 2.0;
while (epsilon > 0.001) {
double newGuess = (guess + square / guess) / 2.0;
epsilon = Math.abs(square - guess * guess);
guess = newGuess;
}
System.out.println("The sqaure root of " + square + " is " + guess);
sc.close();
}
}

@ -0,0 +1 @@
Subproject commit c3bc5e1255ffb32e44d700b81f367717df7b25ae

@ -0,0 +1 @@
Subproject commit c8c6099b8ebecf6eba3ae72bdf03bee41d469891