Skip to content

Commit

Permalink
Closing scanners.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hassan-Elseoudy committed Jan 28, 2020
1 parent 4f45c5a commit a1f59c3
Show file tree
Hide file tree
Showing 27 changed files with 29 additions and 4 deletions.
1 change: 1 addition & 0 deletions Conversions/AnyBaseToAnyBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static void main(String[] args) {
}
}
System.out.println(base2base(n, b1, b2));
in.close();
}

/**
Expand Down
1 change: 1 addition & 0 deletions Conversions/AnytoAny.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static void main(String[] args) {
dec /= db;
}
System.out.println(dn);
scn.close();
}

}
1 change: 1 addition & 0 deletions Conversions/DecimalToBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static void bitwiseConversion() {
n >>= 1;
}
System.out.println("\tBinary number: " + b);
input.close();
}

}
3 changes: 1 addition & 2 deletions Conversions/HexToOct.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public static void main(String args[]) {
// convert decimal to octal
octalnum = decimal2octal(decnum);
System.out.println("Number in octal: " + octalnum);


scan.close();
}
}
2 changes: 1 addition & 1 deletion Conversions/HexaDecimalToDecimal.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void main(String args[]) {
and it returns the decimal form in the variable dec_output.
*/
System.out.println("Number in Decimal: " + dec_output);

scan.close();

}
}
1 change: 1 addition & 0 deletions Conversions/OctalToHexadecimal.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public static void main(String args[]) {
// Pass the decimla number to function and get converted Hex form of the number
String hex = DecimalToHex(decimal);
System.out.println("The Hexadecimal equivalant is: " + hex);
input.close();
}
}

1 change: 1 addition & 0 deletions DataStructures/Graphs/BellmanFord.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void go()//Interactive run for understanding the class first time. Assume
System.out.println();
}
}
sc.close();
}
/**
* @param source Starting vertex
Expand Down
1 change: 1 addition & 0 deletions DataStructures/HashMap/Hashing/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static void main(String[] args) {
return;
}
}
In.close();
}
}
}
1 change: 1 addition & 0 deletions DataStructures/Trees/RedBlackBST.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ public void insertDemo() {
printTreepre(root);
break;
}
scan.close();
}

public void deleteDemo() {
Expand Down
1 change: 1 addition & 0 deletions DynamicProgramming/EditDistance.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,6 @@ public static void main(String[] args) {
//ans stores the final Edit Distance between the two strings
int ans = minDistance(s1, s2);
System.out.println("The minimum Edit Distance between \"" + s1 + "\" and \"" + s2 + "\" is " + ans);
input.close();
}
}
1 change: 1 addition & 0 deletions DynamicProgramming/Fibonacci.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static void main(String[] args) {
System.out.println(fibMemo(n));
System.out.println(fibBotUp(n));
System.out.println(fibOptimized(n));
sc.close();
}

/**
Expand Down
1 change: 1 addition & 0 deletions DynamicProgramming/LongestIncreasingSubsequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static void main(String[] args) {
}

System.out.println(LIS(ar));
sc.close();
}

private static int upperBound(int[] ar, int l, int r, int key) {
Expand Down
1 change: 1 addition & 0 deletions Maths/PrimeCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static void main(String[] args) {
} else {
System.out.println(n + " is not a prime number");
}
scanner.close();
}

/***
Expand Down
1 change: 1 addition & 0 deletions MinimizingLateness/MinimizingLateness.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ public static void main(String[] args) throws IOException {
System.out.println();
System.out.println("Output Data : ");
System.out.println(lateness);
in.close();
}
}
1 change: 1 addition & 0 deletions Misc/PalindromePrime.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public static void main(String[] args) { // Main funtion
System.out.println("Enter the quantity of First Palindromic Primes you want");
int n = in.nextInt(); // Input of how many first pallindromic prime we want
functioning(n); // calling function - functioning
in.close();
}

public static boolean prime(int num) { // checking if number is prime or not
Expand Down
1 change: 1 addition & 0 deletions Others/Dijkshtra.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,6 @@ else if (i != src) {
System.out.print("-1" + " ");
}
}
in.close();
}
}
1 change: 1 addition & 0 deletions Others/InsertDeleteInArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ public static void main(String[] args) {
}
for (i = 0; i < size2 - 1; i++)
System.out.println(b[i]);
s.close();
}
}
1 change: 1 addition & 0 deletions Others/LowestBasePalindrome.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static void main(String[] args) {
}
System.out.println(n + " is a palindrome in base " + lowestBasePalindrome(n));
System.out.println(base2base(Integer.toString(n), 10, lowestBasePalindrome(n)));
in.close();
}

/**
Expand Down
1 change: 1 addition & 0 deletions Others/PerlinNoise.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,6 @@ public static void main(String[] args) {

System.out.println();
}
in.close();
}
}
2 changes: 1 addition & 1 deletion Others/PowerOfTwoOrNot.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static void main(String[] args) {
} else {
System.out.println("Number is not a power of two");
}
sc.close();
}


Expand All @@ -32,5 +33,4 @@ public static void main(String[] args) {
public static boolean checkIfPowerOfTwoOrNot(int number) {
return number != 0 && ((number & (number - 1)) == 0);
}

}
1 change: 1 addition & 0 deletions Others/ReturnSubsequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static void main(String[] args) {
for (int i = 0; i < subsequence.length; i++) {
System.out.println(subsequence[i]);
}
s.close();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Others/RootPrecision.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public static void main(String[] args) {
// P is precision value for eg - P is 3 in 2.564 and 5 in 3.80870.
int P = scn.nextInt();
System.out.println(squareRoot(N, P));

scn.close();
}

public static double squareRoot(int N, int P) {
Expand Down
1 change: 1 addition & 0 deletions Others/SJF.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Schedule {
processes.add(p);
burstAll += p.burstTime;
}
in.close();

}

Expand Down
2 changes: 2 additions & 0 deletions Others/StackPostfixNotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String post = scanner.nextLine(); // Takes input with spaces in between eg. "1 21 +"
System.out.println(postfixEvaluate(post));
scanner.close();
}

// Evaluates the given postfix expression string and returns the result.
Expand Down Expand Up @@ -35,6 +36,7 @@ public static int postfixEvaluate(String exp) {
// "+", "-", "*", "/"
}
}
tokens.close();
return s.pop();
}
}
1 change: 1 addition & 0 deletions Others/TopKWords.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public static void main(String[] args) {
for (int i = 0; i < k; i++) {
System.out.println(list.get(list.size() - i - 1));
}
input.close();
}
}

1 change: 1 addition & 0 deletions Others/TowerOfHanoi.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int numberOfDiscs = scanner.nextInt(); //input of number of discs on pole 1
shift(numberOfDiscs, "Pole1", "Pole2", "Pole3"); //Shift function called
scanner.close();
}
}
1 change: 1 addition & 0 deletions ciphers/Caesar.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public static void main(String[] args) {
case 'd':
System.out.println("DECODED MESSAGE IS \n" + decode(message, shift));
}
input.close();
}

}

0 comments on commit a1f59c3

Please sign in to comment.