Print Censored if userInput contains the word darn else prin

Print \"Censored\" if userInput contains the word \"darn\", else print userInput. End with newline. \"Print\"

Solution

CensoredWords.java


public class CensoredWords {

  
   public static void main(String[] args) {
       String userInput = \"\";
       userInput = \"That darn cat.\";
       if(userInput.contains(\"darn\")){
           System.out.println(\"Censored\");
       }

           return ;
   }

}

Output:

Censored

 Print \
 Print \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site