Question: Write a method in java named swearFilter(String text, String[] swear) that takes two parameters: a String containing some text, and an array of Strings containing

Write a method in java named swearFilter(String text, String[] swear) that takes two parameters: a String containing some text, and an array of Strings containing a list of "swear words". Your method will return a String containing the text contained in the first String, where each "swear word" is replaced by its first character, followed by a number of stars equal to the its number of characters minus two, followed by its last character. For example, if the swear words are "duck", "ship", and "whole", and the text contains the following story:

A duck was sailing on a ship shipping whole wheat bread. Duck that SHIP!!! 

Your method would return:

A d**k was sailing on a s**p s**pping w***e wheat bread. D**k that S**P!!! 

Notice that your method should recognize both uppercase and lowercase characters in a swear word.

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!