Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ * Given a string, return true if it ends in ly . endsLy ( oddly ) - > true endsLy

/*
Given a string, return true if it ends in "ly".
endsLy("oddly")-> true
endsLy("y")-> false
endsLy("oddy")-> false
*/
public boolean endsLy(String str){
return false;
}
/*
Given a string and an int n, return a string made of the first and last n chars from the string. The
string length will be at least n.
nTwice("Hello",2)-> "Helo"
nTwice("Chocolate",3)-> "Choate"
nTwice("Chocolate",1)->"Ce"
*/
public String nTwice(String str, int n){
return null;
}
/*
Given a string and an int n, return a string that starts at n and has a length of 2. Note that n may or may not be a valid
location in the string. If n is too low or too high to define a string of length 2, return the string's first 2 characters.
The string length will be at least 2.
twoChar("java",0)->"ja"
twoChar("java",2)->"va"
twoChar("java",3)->"ja"
*/
public String twoChar(String str, int n){
return null;
}
/*
Given a string of odd length, return the string length 3 from its middle, so "Candy" yields "and".
The string length will be at least 3.
middleThree("Candy")-> "and"
middleThree("and")-> "and"
middleThree("solving")-> "lvi"
*/
public String middleThree(String str){
return null;
}
/*
Given a string, return true if "bad" appears starting at index 0 or 1 in the string, such as with
"badxxx" or "xbadxx" but not "xxbadxx". The string may be any length, including 0. Note: use .equals()
to compare 2 strings.
hasBad("badxx")-> true
hasBad("xbadxx")-> true
hasBad("xxbadxx")-> false
*/
public boolean hasBad(String str){
return false;
}
/*
Given a string and a non-negative int n, return a larger string that is n copies of the original string.
stringTimes("Hi",2)-> "HiHi"
stringTimes("Hi",3)-> "HiHiHi"
stringTimes("Hi",1)->"Hi"
*/
public String stringTimes(String str, int n){
return null;
}
/*
Given a string and a non-negative int n, we'll say that the front of the string is the first 3 chars, or
whatever is there if the string is less than length 3. Return n copies of the front;
frontTimes("Chocolate",2)-> "ChoCho"
frontTimes("Chocolate",3)-> "ChoChoCho"
frontTimes("Abc",3)-> "AbcAbcAbc"
*/
public String frontTimes(String str, int n){
return null;
}
/*
Count the number of "xx" in the given string. We'll say that overlapping is allowed, so "xxx" contains 2"xx".
countXX("abcxx")->1
countXX("xxx")->2
countXX("xxxx")->3
*/
public int countXX(String str){
return 0;
}
/*
Given a string, return true if the first instance of "x" in the string is immediately followed by another "x".
doubleX("axxbb")-> true
doubleX("axaxax")-> false
doubleX("xxxxx")-> true
*/
public boolean doubleX(String str){
return false;
}
/*
Given a string, return a new string made of every other char starting with the first, so "Hello" yields "Hlo".
stringBits("Hello")-> "Hlo"
stringBits("Hi")->"H"
stringBits("Heeololeo")-> "Hello"
*/
public String stringBits(String str){
return null;
}
/*
Given a non-empty string like "Code" return a string like "CCoCodCode".
stringSplosion("Code")-> "CCoCodCode"
stringSplosion("abc")-> "aababc"
stringSplosion("ab")-> "aab"
*/
public String stringSplosion(String str){
return null;
}
/*
Given a string, return the count of the number of times that a substring length 2 appears in the string and
also as the last 2 chars of the string.
We don't count the end subString, so "hixxxhi" yields 1, but the subString may overlap a prior position by one.
For instance, "xxxx" has a count of 2: one pair at position 0, and the second at position 1. The third pair at
position 2 is the end subString, which we don't count.
last2("hixxhi")->1
last2("xaxxaxaxx")->1
last2("axxxaaxx")->2
last2("xxxx")->2
*/
public int last2(String str){
return 0;
}
/*
Given a string, return a version where all the "x" have been removed. Except an "x" at the very start or end
should not be removed.
stringX("xxHxix")-> "xHix"
stringX("abxxxcd")-> "abcd"
stringX("xabxxxcdx")-> "xabcdx"
*/
public String stringX(String str){
return null;
}
/*
Given a string, return a string made of the chars at indexes 0,1,4,5,8,9... so "kittens" yields "kien".
altPairs("kitten")-> "kien"
altPairs("Chocolate")-> "Chole"
altPairs("CodingHorror")-> "Congrr"
*/
public String altPairs(String str){
return null;
}
/*
Suppose the string "yak" is unlucky. Given a string, return a version where all the "yak" are removed.
The "yak" strings will not overlap.
stringYak("yakpak")-> "pak"
stringYak("pakyak")-> "pak"
stringYak("yak123ya")->"123ya"
*/
public String stringYak(String str){
return null;
}
}java

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 2 Lnai 6322

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215882X, 978-3642158827

More Books

Students also viewed these Databases questions

Question

Discuss the Hawthorne experiments in detail

Answered: 1 week ago

Question

Explain the characteristics of a good system of control

Answered: 1 week ago

Question

State the importance of control

Answered: 1 week ago

Question

What are the functions of top management?

Answered: 1 week ago