Question: In 3.15 Program: Text message expander (Java) Im stuck on one thing everything else is righ,t here is my code. import java.util.Scanner; public class TextMsgExpander

In 3.15 Program: Text message expander (Java) Im stuck on one thing everything else is righ,t here is my code.

import java.util.Scanner;

public class TextMsgExpander { public static void main(String[] args) { /* Type your code here. */ String textMsg; String BFF="best friend forever"; String IDK="I don't know"; String JK="just kidding"; String TMI="too much information"; String TTYL="talk to you later"; System.out.println("Enter text: "); Scanner scnr = new Scanner(System.in); textMsg=scnr.nextLine(); System.out.println("You entered: "+textMsg); if(textMsg.contains("BFF")) { textMsg=textMsg.replace("BFF",BFF); System.out.println("Replaced "BFF" with "" + BFF + """ + "."); }

if(textMsg.contains("IDK")) { textMsg=textMsg.replace("IDK",IDK);

System.out.println("Replaced "IDK" with "" + IDK + """ + ".");

} if(textMsg.contains("JK")) { textMsg=textMsg.replace("JK",JK); System.out.println("Replaced "JK" with "" + JK + """ + ".");

} if(textMsg.contains("TMI")) { textMsg=textMsg.replace("TMI",TMI); System.out.println("Replaced "TMI" with "" + TMI + """ + ".");

} if(textMsg.contains("TTYL")) { textMsg=textMsg.replace("TTYL",TTYL); System.out.println("Replaced "TTYL" with ""+ TTYL + """ + ".");

} System.out.println("Expanded: "+textMsg); } }

The top part is mine but the bottom part is what it wants how do I add the spaces there?Input Your output Expected output IDK how that happened. TTYL. Enter text:

Input Your output Expected output IDK how that happened. TTYL. Enter text: You entered: IDK how that happened. TTYL. 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: You entered: IDK how that happened. TTYL. 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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To add the spaces in the output you need to make sure t... View full answer

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 Programming Questions!