This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit b513fedb authored by OEResource sharing's avatar OEResource sharing
Browse files

Update file RepeatCharacterSolution.java for resource with id: b92aaea7-be43-492d-a494-0f1ad5718b4f

parent fd93b55c
No related merge requests found
......@@ -2,28 +2,19 @@ package Solutions;
public class RepeatCharacterSolution {
private static String repeatCharacter(String text, int number, char target) {
private static String repeatCharacter(String text, int number, char target){
String result = "";
target = Character.toLowerCase(target);
for (int i = 0; i < text.length(); i++) {
char currentChar = text.charAt(i);
if (Character.isUpperCase(currentChar)) {
target = Character.toUpperCase(target);
}
if (currentChar == target) {
if(currentChar == target){
for (int j = 0; j < number; j++) {
result += target;
}
number--;
}
if (currentChar != target) {
} else {
result+= currentChar;
}
if (Character.isUpperCase(target)) {
target = Character.toLowerCase(target);
}
}
return result;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment