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

Java // Strings Using the StringBulderClass write an program that takes this tex

ID: 3729611 • Letter: J

Question

Java // Strings

Using the StringBulderClass write an program that takes this text below and substitutes your name every time there is an "it" or "It". The program also should remove the commas and replace them with colons. Then print the resulting string "It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way-- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only."

Explanation / Answer

import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String name=sc.nextLine(); String original="It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way-- in short, the period was so for like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only."; String newString = original.replace('(?i)it', name); System.out.println( newString ); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote