In 3.15 Program: Text message expander (Java) Im stuck on one thing everything else is righ,t here
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 { 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?
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp