(1) Use scnr.nextLine(); to get a line of user input into a string. Output that line. Ex: Enter the text (enter quit to quit): 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. 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 (enter quit to quit): 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. (3) Now make the program repeatedly ask the user to enter a text until the user decides to quit. The user should enter "quit" to quit. Ex: Enter text (enter quit to quit): 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. Enter the text (enter quit to quit): IDK. TMI. You entered: IDK. TMI. Replaced "IDK" with "I don't know". Replaced "TMI" with "too much information". Expanded: I don't know. too much information. Enter the text (enter quit to quit): quit Code: import java.util.Scanner; public class TextMsgExpander { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); /* Type your code here. */ } }
(1) Use scnr.nextLine(); to get a line of user input into a string. Output that line.
Ex:
Enter the text (enter quit to quit):
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.
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 (enter quit to quit):
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.
(3) Now make the
Ex:
Enter text (enter quit to quit):
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.
Enter the text (enter quit to quit):
IDK. TMI.
You entered: IDK. TMI.
Replaced "IDK" with "I don't know".
Replaced "TMI" with "too much information".
Expanded: I don't know. too much information.
Enter the text (enter quit to quit):
quit
Code:
import java.util.Scanner;
public class TextMsgExpander {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
/* Type your code here. */
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images