Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java String and Loop question So I'm writing this program which prompts user to enter a paragraph and the specific word that they want to

Java String and Loop question

So I'm writing this program which prompts user to enter a paragraph and the specific word that they want to censor and eventually output the censored paragraph. How to sensor the wanted word only? Here, it censors whatever letter that appears in the word which needed to be censored.

For example:

Paragraph: Apple is a type of fruit

word needed to be censored with *: apple

Output: ***** is a type of fruit

image text in transcribedimage text in transcribed

public class Randomt public static void main(String[largs) f Scanner input = new Scanner(System.in); System.out.println("Please enter the paragraph you would like filtered: "); String paragraph input.nextLine); System.out.println("Please enter the word you would like to censor: "); String word 1nput.nextLine(); System.out.println("Uncensored:") System.out.println(paragraph); paragraph = paragraph. toLowerCase(); word = word, toLowerCase(), trim(); { (int i= 0; paragraph = paragraph. replace(String.valueOf(word. charAt(i)), for iaord. length(); i++) replacement: "x"); System.out.println("Censored: "paragraph)

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

More Books

Students also viewed these Databases questions

Question

You have

Answered: 1 week ago