Question
Prompt the user to enter a text abbreviation as shown in the sample run below. Requirements: You should use a method called getAbbreviation() that will
Prompt the user to enter a text abbreviation as shown in the sample run below.
Requirements: You should use a method called getAbbreviation() that will be called from the main method. It should prompt for the abbreviation, read it in and return the string that was input to the main method. Remember to declare the scanner in the main method and pass it as a parameter to getAbbreviation().
Evaluate the user's input and decode the abbreviation.
Requirements: Pass the user input string from the main into a method called decodeAbbreviation(). If the user's input string matches a known text message abbreviation that your program handles, your method should return the decoded abbreviation string. If it does not match any abbreviation that your program handles, your method should return the message string "I'm sorry. I don't know that abbreviation. Ask your teen." (see sample run). This method should be case-insensitive meaning that if the user enters "f2f" your decodeAbbreviation() should return that appropriate match for F2F. TIP: You will need to use the String .equals method to compare two Strings. You'll also want to incorporate Watch your case to ensure your output matches the output indicated.
Print the decoded abbreviation.
Requirements: Pass the decoded abbreviation string from the main into a method called printAbbreviation() whose job is to print the decoded message output or the appropriate not found message.
Develop your program so that it initially supports these abbreviations:
F2F-- Face to face
FYEO -- For your eyes only
POS -- Parent over shoulder
JSYK -- Just so you know
PAN -- Parents are near
WCISY -- When can I see you?
LIT -- Cool or favorable
Sample input/output:
Welcome to Decipher Your Teen's Texts! Enter your teen's texting abbreviation: PAN <--- the user entered PAN This means "Parents are near" <-- this is a println
Welcome to Decipher Your Teen's Texts! Enter your teen's texting abbreviation: JSKY I'm sorry. I don't know that abbreviation. Ask your teen.
Required Decomposition:
public static String getAbbreviation(Scanner scnr) - Accepts the scanner object and prompts the user to enter the text abbreviation to be decoded. Returns the string entered by the user to the main.
public static String decodeAbbreviation(String userString) - Accepts the userString that was input and attempts to decode the abbreviation. Returns the decoded abbreviation to the main or appropriate message if the abbreviation cannot be decoded.
public static void printAbbreviation(String result) - Accepts the decoded abbreviation and prints the appropriate message to the screen.
Tips:
trim() method - This is a handy string method that trims any leading or trailing blanks off a string. For instance if str1 contained the string " H ello ", then str1.trim() would return "H ello" and if str1 contained "POS ", then str1.trim would return "POS". In other words, trim does not get rid of any blanks except leading or trailing.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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