Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

learn.zybooks.com SparkNotes: The Glass Mena\". ; Learn.zybooks.com SparkNote..,

ID: 3884889 • Letter: L

Question

learn.zybooks.com SparkNotes: The Glass Mena". ; Learn.zybooks.com SparkNote.., javaswitch case- 3.18. Ch 3 Program;Text mes38. (4) -lavascanner 2 {4) avascanner." scanner java- O0 zyBooks Library» CSCE 155A home-3.18: Ch 3 Program: Text message expander (Java) @ Help / FAQ Bojun Zhong (1) Use scnr.nextLine) to get a line of user input into a string. Output that line. (1 pt) 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: BFF best friend forever IDK I don't know JK-just kidding TMI- too much information TTYL-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

import java.util.Scanner;

public class TestMsgExpander {

public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.print("enter text:");

Scanner input = new Scanner (System.in);

String name = input.nextLine();

System.out.println("you entered " + name);

if(name.matches("IDK")) {

System.out.println("Replaced IDK WITH I DON'T KNOW");

}

if(name.matches("ttyl")) {

System.out.println("replaced ttyl with talk to you later");

}

String name_idk = name.replace("IDK", "I DON'T KNOW");

String name_ttyl = name_idk.replace("ttyl", "talk to you later");

System.out.println("expanded " + name_ttyl);

}

}