Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started