Question: Please use while loop to pass the codecheck. https://codecheck.it/files/1810151907c23deqcckw5m099s8amd3jyji /** * Using the Counter-controlled while Loop. * * @author * @version */ public class PS11A
Please use while loop to pass the codecheck.
https://codecheck.it/files/1810151907c23deqcckw5m099s8amd3jyji /** * Using the Counter-controlled while Loop. * * @author * @version */ public class PS11A { /** * Write the method xyzMiddle(). * * Given a String str, does "xyz" appear in the * "middle" of the string. To define middle, we'll * say that the number characters to the left and * right of the "xyz" must differ by, at most, one. * * Examples: * xyzMiddle("AAxyzBB") returns true * xyzMiddle("AxyzBB") returns true * xyzMiddle("AxyzBBB") returns false * * @param str the String to examine. * @return true if xyz is in the "middle" of str. */ // TODO - Write the method xyZMiddle here.
/** * Write the method named repeatSeparator(). * * Given two String inputs, word and separator, * along with a third int input count, return a * big String consisting of count copies of word, * each separated by separator. * * Note: This is a very common algorithm, called the * fencepost algorithm, because just like building a * fence, you need 11 fenceposts to hold up 10 sections * of fence. * * Examples: * repeatSeparator("Word", "X", 3) returns "WordXWordXWord" * repeatSeparator("This", "And", 2) returns "ThisAndThis" * repeatSeparator("This", "And", 1) returns "This" * * @param word the first String parameter. * @param separator the second String parameter. * @param count the number of times to repeat word. * @return a new String as described here. */ // TODO - Write the repeatSeparator method here.
/** * Write the method named sameStarChar(). * * Given a String str, return true if for every * '*' (star) in the string, if there are chars * both immediately before and after the star, * they are the same. * * Note: This is a little tricker than it looks. * One way to look at the problem is to see in * what circumstances you should return false. * You only return false if the characters on * either side of the * are different. That means * that if there are no characters in front of, * or behind the *, then you should return true, not false. * * Examples: * sameStarChar("xy*yzz") returns true * sameStarChar("xy*zzz") returns false * sameStarChar("*xa*az") returns true * * @param str the input String to process. * @return true if the characters before and after are the same. */ // TODO - Write the sameStarChar method here.
}
.Please pass the code
https://codecheck.it/files/18101518574f8o7qqm8pg9vgllvvxsvbooh
/** * Writing methods using loops. You may use * any kind of loop you like. * * @author * @version */ public class PS11B { /** * Write the method named withoutString(). * * Given two strings, base and remove, return a * version of the base string where all instances * of the remove string have been removed (not case * sensitive). You may assume that the remove * string is length 1 or more. Remove only non-overlapping * instances, so with "xxx" removing "xx" leaves "x". * * Note: Despite the term "remove" you should actually not * try to remove the characters from a string. You'll continue * to use the "building a string" pattern from lecture. * * Examples: * withoutString("Hello there", "llo") returns "He there" * withoutString("Hello there", "e") returns "Hllo thr" * withoutString("Hello there", "x") returns "Hello there" * * @param base the base String to modify. * @param remove the substring to remove. * @return the base String with all copies of remove removed. */ // TODO - Write the withoutString method here
/** * Write the method named sameEnds(). * * Given a string, return the longest substring * that appears at both the beginning and end of * the string without overlapping. For example, * sameEnds("abXab") should return "ab". * * Examples: * sameEnds("abXYab") returns "ab" * sameEnds("xx") returns "x" * sameEnds("xxx") returns "x" * * @param str the String to search. * @return the longest substring that appears at beginning and end. */ // TODO - Write the sameEnds method here.
/** * Write the method named maxBlock(). * * Given a string, return the length of the * largest "block" in the string. A block is a run * of adjacent characters that are the same. * * Examples: * maxBlock("hoopla") returns 2 * maxBlock("abbCCCddBBBxx") returns 3 * maxBlock("") returns 0 * * @param str the String to examine. * @return the size of the longest run of adjacent characters. */ // TODO - Write the maxBlock method here.
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
