Skip to content

Commit 2f89b98

Browse files
committed
solve build error, fix checkstyle and clang-format
1 parent 0b47db6 commit 2f89b98

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/main/java/com/thealgorithms/conversions/WordsToNumber.java

+7-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.util.HashMap;
77
import java.util.List;
88

9-
109
/**
1110
A Java-based utility for converting English word representations of numbers
1211
into their numeric form. This utility supports whole numbers, decimals,
@@ -112,8 +111,7 @@ public static String convert(String numberInWords) {
112111

113112
if (chunks.isEmpty() || isAdditionSafe(chunks.getLast(), nextChunk)) {
114113
chunks.add(nextChunk);
115-
}
116-
else {
114+
} else {
117115
return "Invalid Input. Unexpected Word: " + word;
118116
}
119117
currentChunk = BigDecimal.ZERO;
@@ -131,8 +129,7 @@ public static String convert(String numberInWords) {
131129

132130
if (currentChunkIsZero || isAdditionSafe(currentChunk, bigDecimalNumber)) {
133131
currentChunk = currentChunk.add(bigDecimalNumber);
134-
}
135-
else {
132+
} else {
136133
return "Invalid Input. Unexpected Word: " + word;
137134
}
138135
continue;
@@ -147,8 +144,7 @@ public static String convert(String numberInWords) {
147144
String decimalPart = convertDecimalPart(wordDeque);
148145
if (!decimalPart.startsWith("I")) {
149146
chunks.add(new BigDecimal(decimalPart));
150-
}
151-
else {
147+
} else {
152148
return decimalPart;
153149
}
154150
break;
@@ -204,8 +200,7 @@ private static String convertDecimalPart(ArrayDeque<String> wordDeque) {
204200
Integer number = NUMBER_MAP.getOrDefault(word, null);
205201
if (number != null) {
206202
decimalPart.append(number);
207-
}
208-
else {
203+
} else {
209204
return "Invalid Input. Unexpected Word (after Point): " + word;
210205
}
211206
}
@@ -218,7 +213,9 @@ private static String convertDecimalPart(ArrayDeque<String> wordDeque) {
218213

219214
private static BigDecimal combineChunks(List<BigDecimal> chunks) {
220215
BigDecimal completeNumber = BigDecimal.ZERO;
221-
for (BigDecimal chunk : chunks) completeNumber = completeNumber.add(chunk);
216+
for (BigDecimal chunk : chunks) {
217+
completeNumber = completeNumber.add(chunk);
218+
}
222219
return completeNumber;
223220
}
224221

0 commit comments

Comments
 (0)