Question: When I have a sentence it doesnt detect the profanity. Suppose that we are working for an online service that provides a bulletin board for

 When I have a sentence it doesnt detect the profanity. Supposethat we are working for an online service that provides a bulletin

When I have a sentence it doesnt detect the profanity.

Suppose that we are working for an online service that provides a bulletin board for its users. We would like to give our users the option of filtering out profanity. Suppose that we consider the words cat, dog, and llama to be profane. Write a program that reads a string from the keyboard and tests whether the string contains one of our profane words. Your program should find words like cAt that differ only in case. Input Notes: The input to this program is a single line of text, terminated by a newline. Java ProfaneFilter Interactive Session Enter a line to be checked for profanity: dog cat llama Your input line contains cat contains dog contains llama This line would be considered profane. import java . util . Scanner; /** * * @ author Krane */public class Profane Filter public static void main (String [ ] args) { Sting name; int case_num = 0; Scanner keyboard = new Scanner(System.in); System . out.println("Enter sentences"); name = keyboard . next( ); boolean equalsIgnoreCase = name. equalsIgnoreCase (name) ; if (name . contains("cat ")) { > else if (name . contains("dog")) { case_num =1; } else if (name . contains ("llama") ) { case_num =1; } else { case_num =1; } switch(case_num) { case 1: System . out . println("Profanity found"); break; default: System . out . println("none found"); } } }

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!