Question: This is my code... import java.util.Scanner; public class TextMsgExpander { public static void main(String[] args) { //Declaring String variables String txtMsg,mesg,replaced ; //Scanner Object is

This is my code...

import java.util.Scanner; public class TextMsgExpander { public static void main(String[] args) { //Declaring String variables String txtMsg,mesg,replaced ; //Scanner Object is used to get the inputs entered by the user Scanner sc=new Scanner(System.in);

String BFF="best friend forever"; String IDK="I don't know"; String TMI="Too much information"; String LOL="Laughing out loud"; String IMHO="In my honest opinion"; String TTYL="talk to you later"; String JK="just kidding"; //Getting the inputs entered by the user. System.out.println("Enter text: "); txtMsg=sc.nextLine();

//Displaying the user entered Input String System.out.println("You entered: "+txtMsg+" "); // Check whether the entered string contains Particular string or not if(txtMsg.contains("BFF")) { txtMsg=txtMsg.replace("BFF",BFF); System.out.println("Replaced \"BFF\" with "+BFF); }

// Check whether the entered string contains Particular string or not if(txtMsg.contains("IDK")) { txtMsg=txtMsg.replace("IDK",IDK); System.out.println("Replaced \"IDK\" with \""+IDK+"\""); }

// Check whether the entered string contains Particular string or not if(txtMsg.contains("TMI")) { txtMsg=txtMsg.replace("TMI",TMI); System.out.println("Replaced \"TMI\" with \""+TMI+"\""); }

// Check whether the entered string contains Particular string or not if(txtMsg.contains("LOL")) { txtMsg=txtMsg.replace("LOL",LOL); System.out.println("Replaced \"LOL\" with \""+LOL+"\""); }

// Check whether the entered string contains Particular string or not if(txtMsg.contains("IMHO")) { txtMsg=txtMsg.replace("IMHO",IMHO); System.out.println("Replaced \"IMHO\" with \""+IMHO+"\""); }

// Check whether the entered string contains Particular string or not if(txtMsg.contains("TTYL")) { txtMsg=txtMsg.replace("TTYL",TTYL); System.out.println("Replaced \"TTYL\" with \""+TTYL+"\""); }

// Check whether the entered string contains Particular string or not if(txtMsg.contains("JK")) { txtMsg=txtMsg.replace("JK",JK); System.out.println("Replaced \"JK\" with \""+JK+"\""); } //Displaying the expanded form. System.out.println(" Expanded: "+txtMsg); } }

my output results are as follows and I need to add a . to the end of some lines and don't know how...

This is my code... import java.util.Scanner; public class TextMsgExpander { public staticvoid main(String[] args) { //Declaring String variables String txtMsg,mesg,replaced ; //Scanner Objectis used to get the inputs entered by the user Scanner sc=new

2. Compare output IDK how that happened. TTYL. Input Enter text: You entered: IDK how that happened. TTYL . Your output Replaced "IDK" with "I don't know" Replaced "TTYL" with "talk to you later" Expanded: I don't know how that happened. talk to you later. Enter text: tered: IDK how that happened. TTYL. Expected output Rep laced "IDK"with "I don't know" Replaced "TTYL" with "talk to you later" Expanded: I don't know how that happened. talk to you later

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!