Merge pull request #1217 from Hassan-Elseoudy/master

Closing scanners.
This commit is contained in:
nikhil kala 2020-01-28 22:11:19 +05:30 committed by GitHub
commit 926ed2e10a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 29 additions and 4 deletions

View File

@ -52,6 +52,7 @@ public class AnyBaseToAnyBase {
} }
} }
System.out.println(base2base(n, b1, b2)); System.out.println(base2base(n, b1, b2));
in.close();
} }
/** /**

View File

@ -24,6 +24,7 @@ public class AnytoAny {
dec /= db; dec /= db;
} }
System.out.println(dn); System.out.println(dn);
scn.close();
} }
} }

View File

@ -53,6 +53,7 @@ class DecimalToBinary {
n >>= 1; n >>= 1;
} }
System.out.println("\tBinary number: " + b); System.out.println("\tBinary number: " + b);
input.close();
} }
} }

View File

@ -64,7 +64,6 @@ public class HexToOct {
// convert decimal to octal // convert decimal to octal
octalnum = decimal2octal(decnum); octalnum = decimal2octal(decnum);
System.out.println("Number in octal: " + octalnum); System.out.println("Number in octal: " + octalnum);
scan.close();
} }
} }

View File

@ -34,7 +34,7 @@ public class HexaDecimalToDecimal {
and it returns the decimal form in the variable dec_output. and it returns the decimal form in the variable dec_output.
*/ */
System.out.println("Number in Decimal: " + dec_output); System.out.println("Number in Decimal: " + dec_output);
scan.close();
} }
} }

View File

@ -59,6 +59,7 @@ public class OctalToHexadecimal {
// Pass the decimla number to function and get converted Hex form of the number // Pass the decimla number to function and get converted Hex form of the number
String hex = DecimalToHex(decimal); String hex = DecimalToHex(decimal);
System.out.println("The Hexadecimal equivalant is: " + hex); System.out.println("The Hexadecimal equivalant is: " + hex);
input.close();
} }
} }

View File

@ -100,6 +100,7 @@ start vertex, end vertes and weights. Vertices should be labelled with a number
System.out.println(); System.out.println();
} }
} }
sc.close();
} }
/** /**
* @param source Starting vertex * @param source Starting vertex

View File

@ -42,6 +42,7 @@ public class Main {
return; return;
} }
} }
In.close();
} }
} }
} }

View File

@ -309,6 +309,7 @@ public class RedBlackBST {
printTreepre(root); printTreepre(root);
break; break;
} }
scan.close();
} }
public void deleteDemo() { public void deleteDemo() {

View File

@ -74,5 +74,6 @@ public class EditDistance {
//ans stores the final Edit Distance between the two strings //ans stores the final Edit Distance between the two strings
int ans = minDistance(s1, s2); int ans = minDistance(s1, s2);
System.out.println("The minimum Edit Distance between \"" + s1 + "\" and \"" + s2 + "\" is " + ans); System.out.println("The minimum Edit Distance between \"" + s1 + "\" and \"" + s2 + "\" is " + ans);
input.close();
} }
} }

View File

@ -22,6 +22,7 @@ public class Fibonacci {
System.out.println(fibMemo(n)); System.out.println(fibMemo(n));
System.out.println(fibBotUp(n)); System.out.println(fibBotUp(n));
System.out.println(fibOptimized(n)); System.out.println(fibOptimized(n));
sc.close();
} }
/** /**

View File

@ -17,6 +17,7 @@ public class LongestIncreasingSubsequence {
} }
System.out.println(LIS(ar)); System.out.println(LIS(ar));
sc.close();
} }
private static int upperBound(int[] ar, int l, int r, int key) { private static int upperBound(int[] ar, int l, int r, int key) {

View File

@ -13,6 +13,7 @@ public class PrimeCheck {
} else { } else {
System.out.println(n + " is not a prime number"); System.out.println(n + " is not a prime number");
} }
scanner.close();
} }
/*** /***

View File

@ -53,5 +53,6 @@ public class MinimizingLateness {
System.out.println(); System.out.println();
System.out.println("Output Data : "); System.out.println("Output Data : ");
System.out.println(lateness); System.out.println(lateness);
in.close();
} }
} }

View File

@ -9,6 +9,7 @@ public class PalindromePrime {
System.out.println("Enter the quantity of First Palindromic Primes you want"); 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 int n = in.nextInt(); // Input of how many first pallindromic prime we want
functioning(n); // calling function - functioning functioning(n); // calling function - functioning
in.close();
} }
public static boolean prime(int num) { // checking if number is prime or not public static boolean prime(int num) { // checking if number is prime or not

View File

@ -80,5 +80,6 @@ public class Dijkshtra {
System.out.print("-1" + " "); System.out.print("-1" + " ");
} }
} }
in.close();
} }
} }

View File

@ -44,5 +44,6 @@ public class InsertDeleteInArray {
} }
for (i = 0; i < size2 - 1; i++) for (i = 0; i < size2 - 1; i++)
System.out.println(b[i]); System.out.println(b[i]);
s.close();
} }
} }

View File

@ -29,6 +29,7 @@ public class LowestBasePalindrome {
} }
System.out.println(n + " is a palindrome in base " + lowestBasePalindrome(n)); System.out.println(n + " is a palindrome in base " + lowestBasePalindrome(n));
System.out.println(base2base(Integer.toString(n), 10, lowestBasePalindrome(n))); System.out.println(base2base(Integer.toString(n), 10, lowestBasePalindrome(n)));
in.close();
} }
/** /**

View File

@ -162,5 +162,6 @@ public class PerlinNoise {
System.out.println(); System.out.println();
} }
in.close();
} }
} }

View File

@ -20,6 +20,7 @@ public class PowerOfTwoOrNot {
} else { } else {
System.out.println("Number is not a power of two"); System.out.println("Number is not a power of two");
} }
sc.close();
} }
@ -32,5 +33,4 @@ public class PowerOfTwoOrNot {
public static boolean checkIfPowerOfTwoOrNot(int number) { public static boolean checkIfPowerOfTwoOrNot(int number) {
return number != 0 && ((number & (number - 1)) == 0); return number != 0 && ((number & (number - 1)) == 0);
} }
} }

View File

@ -13,6 +13,7 @@ public class ReturnSubsequence {
for (int i = 0; i < subsequence.length; i++) { for (int i = 0; i < subsequence.length; i++) {
System.out.println(subsequence[i]); System.out.println(subsequence[i]);
} }
s.close();
} }
/** /**

View File

@ -14,6 +14,8 @@ public class RootPrecision {
// P is precision value for eg - P is 3 in 2.564 and 5 in 3.80870. // P is precision value for eg - P is 3 in 2.564 and 5 in 3.80870.
int P = scn.nextInt(); int P = scn.nextInt();
System.out.println(squareRoot(N, P)); System.out.println(squareRoot(N, P));
scn.close();
} }
public static double squareRoot(int N, int P) { public static double squareRoot(int N, int P) {

View File

@ -67,6 +67,7 @@ class Schedule {
processes.add(p); processes.add(p);
burstAll += p.burstTime; burstAll += p.burstTime;
} }
in.close();
} }

View File

@ -7,6 +7,7 @@ public class StackPostfixNotation {
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
String post = scanner.nextLine(); // Takes input with spaces in between eg. "1 21 +" String post = scanner.nextLine(); // Takes input with spaces in between eg. "1 21 +"
System.out.println(postfixEvaluate(post)); System.out.println(postfixEvaluate(post));
scanner.close();
} }
// Evaluates the given postfix expression string and returns the result. // Evaluates the given postfix expression string and returns the result.
@ -35,6 +36,7 @@ public class StackPostfixNotation {
// "+", "-", "*", "/" // "+", "-", "*", "/"
} }
} }
tokens.close();
return s.pop(); return s.pop();
} }
} }

View File

@ -82,6 +82,7 @@ public class TopKWords {
for (int i = 0; i < k; i++) { for (int i = 0; i < k; i++) {
System.out.println(list.get(list.size() - i - 1)); System.out.println(list.get(list.size() - i - 1));
} }
input.close();
} }
} }

View File

@ -22,5 +22,6 @@ class TowerOfHanoi {
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
int numberOfDiscs = scanner.nextInt(); //input of number of discs on pole 1 int numberOfDiscs = scanner.nextInt(); //input of number of discs on pole 1
shift(numberOfDiscs, "Pole1", "Pole2", "Pole3"); //Shift function called shift(numberOfDiscs, "Pole1", "Pole2", "Pole3"); //Shift function called
scanner.close();
} }
} }

View File

@ -126,6 +126,7 @@ public class Caesar {
case 'd': case 'd':
System.out.println("DECODED MESSAGE IS \n" + decode(message, shift)); System.out.println("DECODED MESSAGE IS \n" + decode(message, shift));
} }
input.close();
} }
} }