3.15 Program: Text message expander (Java) Create a program using conditional lo
ID: 3880666 • Letter: 3
Question
3.15 Program: Text message expander (Java) Create a program using conditional logic and string operations that does the following using your NetBeans IDE and upload it here: Instructor notes (1) Use scnr.nextLine(); to get a line of user input into a string. Output that line. (1 pt) While you will be submitting this assignment through Zybooks, make sure you are still applying appropriate formatting and in-line commenting. Ex: Enter text: IDK how that happened. TTYL You entered: IDK how that happened. TTYL. (2) Expand common text message abbreviations. Output a message for each abbreviation that is expanded, then output the expanded line. Note: Check for abbreviations in the order provided below. (5 pts) Support these abbreviations (you only need to support these): BFF - - best friend forever IDK- Idon't know . JK just kidding . TMI - -too much information ·TYL-talk to you later Ex: Enter text: IDK how that happened. TTYL 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.Explanation / Answer
TextMsgExpander.java
import java.util.Scanner;
/** * * @author jack */
public class TextMsgExpander {
/** * @param args the command line arguments */
public static void main(String[] args) {
// TODO code application logic here
String txtMsg, mesg, replaced;
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 humble opinion";
String TTYL = "talk to you later";
System.out.print("Enter Text :");
txtMsg = sc.nextLine();
System.out.println("You Entered :" + txtMsg + " ");
if (txtMsg.contains("BFF")) {
txtMsg = txtMsg.replace("BFF", BFF);
System.out.println("Replaced 'BFF' with " + BFF);
}
if (txtMsg.contains("IDK")) {
txtMsg = txtMsg.replace("IDK", IDK);
System.out.println("Replaced 'IDK' with "" + IDK + """);
}
if (txtMsg.contains("TMI")) {
txtMsg = txtMsg.replace("TMI", TMI);
System.out.println("Replaced 'TMI' with "" + TMI + """);
}
if (txtMsg.contains("LOL")) {
txtMsg = txtMsg.replace("LOL", LOL);
System.out.println("Replaced 'LOL' with "" + LOL + """);
}
if (txtMsg.contains("IMHO")) {
txtMsg = txtMsg.replace("IMHO", IMHO);
System.out.println("Replaced 'IMHO' with "" + IMHO + """);
}
if (txtMsg.contains("TTYL")) {
txtMsg = txtMsg.replace("TTYL", TTYL);
System.out.println("Replaced 'TTYL' with "" + TTYL + """);
}
System.out.println(" Expanded :" + txtMsg);
}
}
__________________
Output:
Enter Text :IDK how that happened. TTYL.
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.
_______________Could you plz rate me well.Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.