Skip to content

Commit 9a6a84c

Browse files
Refined Variable Names for RemoveStars.java and ComplexNumberMultiplication.java
1 parent 5a0c1cf commit 9a6a84c

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/main/java/com/thealgorithms/strings/ComplexNumberMultiplication.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ private ComplexNumberMultiplication() {
2323
* @return the resulting complex number after multiplication
2424
*/
2525
public static String multiplyComplexNumbers(String num1, String num2) {
26-
int i = num1.indexOf('+');
27-
int j = num2.indexOf('+');
26+
int plusIndex1 = num1.indexOf('+');
27+
int plusIndex2 = num2.indexOf('+');
2828

29-
String r1 = num1.substring(0, i);
30-
String i1 = num1.substring(i + 1, num1.length() - 1);
29+
String realPart1 = num1.substring(0, plusIndex1);
30+
String imagPart1 = num1.substring(plusIndex1 + 1, num1.length() - 1);
3131

32-
int re1 = Integer.parseInt(r1);
33-
int im1 = Integer.parseInt(i1);
32+
int re1 = Integer.parseInt(realPart1);
33+
int im1 = Integer.parseInt(imagPart1);
3434

35-
String r2 = num2.substring(0, j);
36-
String i2 = num2.substring(j + 1, num2.length() - 1);
35+
String realPart2 = num2.substring(0, plusIndex2);
36+
String imagPart2 = num2.substring(plusIndex2 + 1, num2.length() - 1);
3737

38-
int re2 = Integer.parseInt(r2);
39-
int im2 = Integer.parseInt(i2);
38+
int re2 = Integer.parseInt(realPart2);
39+
int im2 = Integer.parseInt(imagPart2);
4040

41-
int reAns = re1 * re2 - im1 * im2;
42-
int imAns = re1 * im2 + im1 * re2;
41+
int reResult = re1 * re2 - im1 * im2;
42+
int imResult = re1 * im2 + im1 * re2;
4343

44-
return reAns + "+" + imAns + "i";
44+
return reResult + "+" + imResult + "i";
4545
}
4646
}

src/main/java/com/thealgorithms/strings/RemoveStars.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ public static String removeStars(String input) {
2424
return input;
2525
}
2626
int n = input.length();
27-
StringBuilder ans = new StringBuilder();
27+
StringBuilder result = new StringBuilder();
2828
for (int i = 0; i < n; i++) {
29-
char t = input.charAt(i);
30-
if (t != '*') {
31-
ans.append(t);
29+
char currentChar = input.charAt(i);
30+
if (currentChar != '*') {
31+
result.append(currentChar);
3232
}
3333
else {
34-
ans.deleteCharAt(ans.length() - 1);
34+
result.deleteCharAt(result.length() - 1);
3535
}
3636
}
37-
return ans.toString();
37+
return result.toString();
3838
}
3939
}

0 commit comments

Comments
 (0)