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: 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
Step: 1
To add the spaces in the output you need to make sure t...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started