Skip to content

Commit f2f7982

Browse files
committed
fix: remove unused imports to fix TheAlgorithms#699
- Fix TheAlgorithms#699 - Thanks @lprone
1 parent cbfa887 commit f2f7982

File tree

2 files changed

+32
-38
lines changed

2 files changed

+32
-38
lines changed

Conversions/HexaDecimalToBinary.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
import java.lang.StringBuilder;
2-
import java.util.*;
3-
import java.util.Scanner;
4-
import javax.swing.*;
5-
61
public class HexaDecimalToBinary {
7-
2+
83
private final int LONG_BITS = 8;
94

105
public void convert(String numHex) {
11-
//String a HexaDecimal:
6+
// String a HexaDecimal:
127
int conHex = Integer.parseInt(numHex, 16);
13-
//Hex a Binary:
8+
// Hex a Binary:
149
String binary = Integer.toBinaryString(conHex);
15-
//Presentation:
10+
// Presentation:
1611
System.out.println(numHex + " = " + completeDigits(binary));
1712
}
1813

@@ -27,7 +22,7 @@ public static void main(String[] args) {
2722

2823
//Testing Numbers:
2924
String[] hexNums = {"1", "A1", "ef", "BA", "AA", "BB",
30-
"19", "01", "02", "03", "04"};
25+
"19", "01", "02", "03", "04"};
3126
HexaDecimalToBinary objConvert = new HexaDecimalToBinary();
3227

3328
for (String num : hexNums) {

Others/RootPrecision.java

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1-
import java.io.*;
2-
import java.util.*;
3-
import java.text.*;
4-
import java.math.*;
5-
import java.util.regex.*;
1+
import java.util.Scanner;
62

73
public class RootPrecision {
84

95
public static void main(String[] args) {
10-
//take input
11-
Scanner scn = new Scanner(System.in);
12-
13-
int N = scn.nextInt(); //N is the input number
14-
int P = scn.nextInt(); //P is precision value for eg - P is 3 in 2.564 and 5 in 3.80870.
15-
16-
System.out.println(squareRoot(N, P));
17-
}
18-
19-
public static double squareRoot(int N, int P) {
20-
double rv = 0; //rv means return value
21-
6+
// take input
7+
Scanner scn = new Scanner(System.in);
8+
9+
// N is the input number
10+
int N = scn.nextInt();
11+
12+
// P is precision value for eg - P is 3 in 2.564 and 5 in 3.80870.
13+
int P = scn.nextInt();
14+
System.out.println(squareRoot(N, P));
15+
}
16+
17+
public static double squareRoot(int N, int P) {
18+
// rv means return value
19+
double rv;
20+
2221
double root = Math.pow(N, 0.5);
23-
24-
//calculate precision to power of 10 and then multiply it with root value.
25-
int precision = (int) Math.pow(10, P);
26-
root = root * precision;
27-
/*typecast it into integer then divide by precision and again typecast into double
28-
so as to have decimal points upto P precision */
29-
30-
rv = (int)root;
31-
return (double)rv/precision;
32-
}
33-
}
22+
23+
// calculate precision to power of 10 and then multiply it with root value.
24+
int precision = (int) Math.pow(10, P);
25+
root = root * precision;
26+
/*typecast it into integer then divide by precision and again typecast into double
27+
so as to have decimal points upto P precision */
28+
29+
rv = (int) root;
30+
return rv / precision;
31+
}
32+
}

0 commit comments

Comments
 (0)