Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

Students also viewed these Databases questions