Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The program repeatedly prompts the user to enter a sentence to be censored. Afte

ID: 3664367 • Letter: T

Question

The program repeatedly prompts the user to enter a sentence to be censored. After a sentence is entered, the program searches for the word "hell" and replaces with "heck". The original and censored sentences are displayed within quotes. The program should continue to ask for sentences to censor until user enters null string. Output should look like following: Enter Sentence ==> Hell, its hot as hell looking for shells in hell! Original : "Hell, its hot as hell looking for shells in hell!" Censored : "Heck, its hot as heck looking for shells in heck!" -------------------------------------------------------------------- Enter Sentence ==> Hello Hell. Original : "Hello Hell." Censored : "Hello Heck."

Explanation / Answer

import java.util.Scanner;


public class Grocery_shopping {

   
   
    public static void main(String[] args) {

    Scanner obj=new Scanner(System.in);
    System.out.println("Enter New sentense");
    String input=obj.nextLine();
    while((input=obj.nextLine())!=null)
    {
        System.out.println("Origional sentense");
        System.out.println(input);
    input=input.replaceAll("(?i)hell","heck");
System.out.println("Sensored Sentense");
    System.out.println(input);
    input=obj.nextLine();
    }
    }

}

sample outputs

Enter New sentense

Hell, its hot as hell looking for shells in hell!
Origional sentense
Hell, its hot as hell looking for shells in hell!
Sensored Sentense
heck, its hot as heck looking for shecks in heck!
Hell, its hot as hell looking for shells in hell!

Origional sentense

Sensored Sentense

Hell, its hot as hell looking for shells in hell!

Origional sentense

Sensored Sentense


Hell, its hot as hell looking for shells in hell!
Origional sentense
Hell, its hot as hell looking for shells in hell!
Sensored Sentense
heck, its hot as heck looking for shecks in heck!

Hell, its hot as hell looking for shells in hell!
Origional sentense
Hell, its hot as hell looking for shells in hell!
Sensored Sentense
heck, its hot as heck looking for shecks in heck!