Question: This method gets two strings (text and badWord) and returns a string. basicly what it dose is take out all the occurrences of badWord in

This method gets two strings (text and badWord) and returns a string.

basicly what it dose is take out all the occurrences of badWord in text.

for example:

clean ("oneTwoThree","Two")

returns "oneThree"

clean ("fooBar","foo")

returns "Bar"

clean ("heSaidBlaBlaBla","Bla")

returns "heSaid "

hint:

https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#replace(char,%20char)

_________________________

import java.util.*;

class Main { // your main method here public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("Enter text:"); String text = scan.next(); System.out.println("Enter badWord:"); String badWord = scan.next(); System.out.println(clean(text, badWord)); } public static String clean (String text, String badWord) { // your code here } }

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!