Question: 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

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

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

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!