Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a static method , getBigWords, that gets a single String parameter and ret

ID: 3797609 • Letter: W

Question

Write a static method , getBigWords, that gets a single String parameter and returns an array whose elements are the words in the parameter that contain more than 5 letters. (A word is defined as a contiguous sequence of letters.) EXAMPLE: So, if the String argument passed to the method was "There are 87,000,000 people in Canada", getBigWords would return an array of two elements , "people" and "Canada". ANOTHER EXAMPLE: If the String argument passed to the method was "Send the request to support@turingscraft.com", getBigWords would return an array of three elements , "request", "support" and "turingscraft".

this is for the pearson

Explanation / Answer

Here is the program what i have so far

public class StackOverFlow

{

public static void main(String[] args)

{

String str1 = "There are 87,000,000 people in Canada";

String str2 = "Send the request to support@turingscraft.com";

String[] bigWordsArray = getBigWords(str1);

System.out.println("Printing results from first String");

for (String string : bigWordsArray)

{

System.out.println(string);

}

bigWordsArray = getBigWords(str2);

System.out.println("Printing results from second String");

for (String string : bigWordsArray)

{

System.out.println(string);

}

}

public static String[] getBigWords(String testString) {

testString = testString.replace('@', ' ');

testString = testString.replace('.', ' ');

testString = testString.replaceAll("\d+.", "");

String[] tokens = testString.split(" ");

StringBuilder sb = new StringBuilder();

for (String string : tokens) {

if (string.length() > 5) {

sb.append(string).append(" ");

}

}

return sb.toString().split(" ");

}

}

The output willbe in the form be like/:

printing results from first string

people

canada

people results from second string

request

support

turingscraft

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote