Problem Statement
SMS messages are short messages sent between mobile phones. The maximum length of a single message is 160 characters, so it is often necessary to abbreviate words.
You are given a String text, and your task is to translate it to SMS language according to the following rules:
- Remove all punctuation symbols ('.', ',', '?' and '!').
- Replace all uppercase letters with their lowercase equivalents.
- Replace all occurrences of "and" with '&'.
- Replace all occurrences of "ate" with '8'.
- Replace all occurrences of "at" with '@'.
- Replace all occurrences of "you" with 'U'.
Definition
- Class:
- SMSLanguage
- Method:
- translate
- Parameters:
- String
- Returns:
- String
- Method signature:
- String translate(String text)
- (be sure your method is public)
Constraints
- text will contain between 1 and 50 characters, inclusive.
- text will contain only letters ('a'-'z', 'A'-'Z'), the characters ',', '.', '!', '?', and spaces (' ').
Examples
"I HATE rats, and you?"
Returns: "i h8 r@s & U"
The example from the problem statement."What is the weather like today?"
Returns: "wh@ is the we@her like today"
"It is not too late to.."
Returns: "it is not too l8 to"
"this text is already in sms language"
Returns: "this text is already in sms language"