Question: 30: repeatEnd Write a function in Java that implements the following logic: Given a string and an int n, return a string made of n

30: repeatEnd

Write a function in Java that implements the following logic: Given a string and an int n, return a string made of n repetitions of the last n characters of the string. You may assume that n is between 0 and the length of the string, inclusive.

public String repeatEnd(String str, int n)

{

}

33: zipZap

Given a string str, find all places where a three-letter combination starting with "z" and ending with "p" occurs. Return a string where for all such three-letter sequences, the middle letter has been removed. For example, a string like "zipXzap" would produce a result of "zpXzp".

public String zipZap(String str)

{

}

35. countCode

Write a function in Java that counts the number of times the string "code" appears anywhere in the given string str, except that we'll accept any letter in place of the 'd', so for example, "cope" and "cooe" count.

public int countCode(String str)

{

}

37. endOther

Given two strings, return true if either of the strings appears at the very end of the other string, ignoring upper/lower case differences (in other words, the computation should not be "case sensitive"). Note: str.toLowerCase() returns the lowercase version of a string.

public boolean endOther(String a, String b)

{

}

38: xyBalance

We'll say that a string is xy-balanced if for all the 'x' characterss in the string, there exists a 'y' character somewhere later in the string. So "xxy" is balanced, but "xyx" is not. One 'y' can balance multiple 'x's. Return true if the given string is xy-balanced.

public boolean xyBalance(String str)

{

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!