Skip to content

Commit 03dbfa7

Browse files
- Closed all Scanner and Buffered Readers
- Added Some Java Doc - ReverseString - took space out of between each letter so "Zachary" to "yrahcaZ" instead of "y r a h c aZ" - bfs - Trying to repair this class but need to research bfs more - dfs - Trying to repair this class but need to research dfs more - Added new Classes 1) OctalToBinary - Not done 2) BinaryToOctal - Not done 3) OctalToDecimal - Not done 4) Graphs -Added the dataStructure Graphs (Unfinished)
1 parent abbc4be commit 03dbfa7

21 files changed

Lines changed: 179 additions & 24 deletions

BinarySearch.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,6 @@ public static void main(String[] args)
7070
{
7171
System.out.println("Not found");
7272
}
73+
input.close();
7374
}
7475
}

BinaryToDecimal.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public static void main(String args[])
1818
{
1919
Scanner sc=new Scanner(System.in);
2020
int n,k,d,s=0,c=0;
21+
System.out.print("Binary number: ");
2122
n=sc.nextInt();
2223
k=n;
2324
while(k!=0)
@@ -26,7 +27,7 @@ public static void main(String args[])
2627
s+=d*(int)Math.pow(2,c++);
2728
k/=10;
2829
}
29-
System.out.println("Binary number:"+n);
3030
System.out.println("Decimal equivalent:"+s);
31+
sc.close();
3132
}
3233
}

BinaryToOctal.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import java.util.Scanner;
2+
3+
/**
4+
* Converts any Binary number to an Octal Number
5+
*
6+
* @author Zachary Jones
7+
*
8+
*/
9+
public class BinaryToOctal {
10+
11+
/**
12+
* Main method
13+
*
14+
* @param args Command line arguments
15+
*/
16+
public static void main(String args[]) {
17+
Scanner sc = new Scanner(System.in);
18+
int b = sc.nextInt();
19+
System.out.println("Octal equivalent: " + convertBinaryToOctal(b));
20+
sc.close();
21+
22+
}
23+
24+
/**
25+
* This method converts a binary number to
26+
* an octal number.
27+
*
28+
* @param b The binary number
29+
* @return The octal number
30+
*/
31+
public static int convertBinaryToOctal(int b) {
32+
33+
}
34+
35+
}

BubbleSort.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ public static void main(String[] args)
4545
{
4646
System.out.print(array[i]+"\t");
4747
}
48-
48+
input.close();
4949
}
5050
}

DecimalToBinary.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public static void main(String args[])
1717
{
1818
Scanner sc=new Scanner(System.in);
1919
int n,k,s=0,c=0,d;
20+
System.out.print("Decimal number: ");
2021
n=sc.nextInt();
2122
k=n;
2223
while(k!=0)
@@ -25,7 +26,7 @@ public static void main(String args[])
2526
s=s+d*(int)Math.pow(10,c++);
2627
k/=2;
2728
}//converting decimal to binary
28-
System.out.println("Decimal number:"+n);
2929
System.out.println("Binary equivalent:"+s);
30+
sc.close();
3031
}
3132
}

DecimalToOctal.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public static void main(String[] args)
1717
{
1818
Scanner sc=new Scanner(System.in);
1919
int n,k,d,s=0,c=0;
20+
System.out.print("Decimal number: ");
2021
n=sc.nextInt();
2122
k=n;
2223
while(k!=0)
@@ -25,7 +26,8 @@ public static void main(String[] args)
2526
s+=d*(int)Math.pow(10,c++);
2627
k/=8;
2728
}
28-
System.out.println("Decimal number:"+n);
29+
2930
System.out.println("Octal equivalent:"+s);
31+
sc.close();
3032
}
3133
}

Factorial.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public static void main(String[] args){
2929
//Output of factorial for any non-negative number
3030
System.out.println("The factorial of "+number+" will yield: "+factorial(number));
3131
}
32-
}
32+
}
33+
input.close();
3334
}
3435

3536
/**

InsertionSort.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ public static void main(String[] args)
4444
{
4545
System.out.print(array[i]+"\t");
4646
}
47-
47+
input.close();
4848
}
4949
}

InsertionSortInteger.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
public class InsertionSortInteger {
1212

1313

14+
/**
15+
* This method implements insertion sort by integer
16+
*
17+
* @param initialArray array to be sorted
18+
* @return sorted array
19+
*/
1420
public int[] insertionIntArraySort(int[] initialArray){
1521

1622
int[] sortedArray = new int[initialArray.length];

LinearSearch.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public static void main(String[] args){
2727
//Output array and index of target element, if found
2828
printarray(myArray);
2929
System.out.printf("The integer %d is found in index %d\n", key, linearsearch(myArray, key));
30-
30+
31+
input.close();
3132
}
3233

3334
/**

0 commit comments

Comments
 (0)