* REQUIREMENT #1 Remove any word in wordList that starts with letter In the test
ID: 3601694 • Letter: #
Question
* REQUIREMENT #1 Remove any word in wordList that starts with letter In the tester, make sure to check the printout of the 1ist before and after the call public void dropletterWords (ArrayList String wordlist, String letter) * The words in wordlist are sorted by the nunber of characters in the words. 1-letter words come first, Add word to the 1ist, ensuring to saintain this property * then 2-letter words, then 3-letter words, etc public void addword(Arraylist wordlist, String word) - Return a new Arraylist of each word in wordList that ends with * pattern. Ensure not to change wordlist.In the tester, ·make sure to check the printout of the main list before and after the cal1 (it should not have changed) public Arraylist strings rhyseSuggestions(Arraylist-string wordlist, String pattern) return nul1; /1 delete this 1ineExplanation / Answer
public void dropLetterWords(ArrayList<Strings> wordList, String letter){
int [] a = new int[50];
count = 0;
for (int i = 0; i <wordList.size(); i++){
if (wordList.get(i).startsWith(letter)){
a[count] = i;
count++;
}
}
for (int i = 0; i<count; i++){
wordList.remove(a[i]);
}
}
public void addWordArrayList(ArrayList<String> wordList, String word){
int found = 0;
int index;
for (int i =0; i<wordList.size(); i++){
if (word.length() <= wordList.get(i).length()){
found = 1;
wordlist.add(i,word);
break;
}
else {
}
}
if (found == 0)
worldList.add(word);
}
public ArrayList<string> addWordArrayList(ArrayList<String> wordList, String pattern){
int found = 0;
int index;
ArrayList<String> temp = new ArrayList<String>();
for (int i =0; i<wordList.size(); i++){
if (wordList.get(i).endsWith(pattern){
temp.add(wordList.get(i));
}
else {
}
}
return temp;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.