Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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?image

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Java Programs A Back To Basics Approach

Authors: Stuart Reges, Marty Stepp

5th Edition

013547194X, 978-0135471944

More Books

Students also viewed these Programming questions

Question

Can a company change its total risk level over time? How?

Answered: 1 week ago

Question

Explain the characteristics of the three types of needs.

Answered: 1 week ago

Question

Recognize some of the factors that contribute to obesity.

Answered: 1 week ago

Question

Identify the physical and social factors that influence hunger.

Answered: 1 week ago