Problem Statement
You are given a
- 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'.
Return the resulting translation as a
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"
"only yoyoyou"
Returns: "only yoyoU"
"only yoyoyoU"
Returns: "only yoyoU"
"only YoYoYoU"
Returns: "only yoyoU"
".,!?"
Returns: ""
"THIS TEXT IS ALREADY IN SMS LANGUAGE"
Returns: "this text is already in sms language"
"ate ateate ate"
Returns: "8 88 8"
"to toto to"
Returns: "to toto to"
"tototototototototototototototototototototototototo"
Returns: "tototototototototototototototototototototototototo"
"ototototototototototototototototototototototototot"
Returns: "ototototototototototototototototototototototototot"
"totoototootooototoootooootootooototoooto"
Returns: "totoototootooototoootooootootooototoooto"
"ateatateateatateateaateteateattteaaeettateatate"
Returns: "8@88@88a8te8@tteaaeett8@8"
"andatforyouyouforatandateatandforyou"
Returns: "&@forUUfor@&8@&forU"
"a,t"
Returns: "@"
"toooooooooo cooooool"
Returns: "toooooooooo cooooool"
"A..at, a t . t a "
Returns: "a@ a t t a "
" "
Returns: " "
",.!?..??!!,......,.!?..??!!,,.!?..??!!,,.!?..??!!,"
Returns: ""
"tootoOtOotOOTooToOTOoTOO"
Returns: "tootootootootootootootoo"
"..qattaq.."
Returns: "q@taq"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
Returns: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"t.......o.........o"
Returns: "too"
"A.T.E"
Returns: "8"
".,Yo u! ! !a!!.t..A.,t.e!....and"
Returns: "yo u @8&"
"HaTe HanD YoU AteaTAte"
Returns: "h8 h& U 8@8"
"a.nd"
Returns: "&"
"a,te"
Returns: "8"
"AZ"
Returns: "az"
"a?te"
Returns: "8"
"ate"
Returns: "8"
"Y.O.U"
Returns: "U"
"at"
Returns: "@"
"a.n.d."
Returns: "&"
"a.te"
Returns: "8"
"a?nd"
Returns: "&"
" a.n.d w,h?a?t about this?? Y.O.U G.R,E,AT.ER"
Returns: " & wh@ about this U gre8r"
"an.d a,t at?e y!ou"
Returns: "& @ 8 U"
"aha?"
Returns: "aha"
" "
Returns: " "
"a,n,?!.d!"
Returns: "&"
"a"
Returns: "a"
" atAtEatatATEATE "
Returns: " @8@@88 "
"at.ea.teate"
Returns: "888"
"yoaaa"
Returns: "yoaaa"
"ate ate"
Returns: "8 8"
"ABC!!h!!!"
Returns: "abch"
"?Y.o.U!"
Returns: "U"
"yo,u are fima"
Returns: "U are fima"
"at.e"
Returns: "8"
"fate"
Returns: "f8"
" ATE uUuyou wet,we.we.tt, pwer? "
Returns: " 8 uuuU wetwewett pwer "
"atande an,d"
Returns: "@&e &"
"a,nd"
Returns: "&"
"an"
Returns: "an"
"an,d"
Returns: "&"
"...a.n.d"
Returns: "&"
"andatand.,.,atateAndyoUUUfrYOUate!!a,te"
Returns: "&@&@8&UuufrU88"
".a.n.d."
Returns: "&"
"i am"
Returns: "i am"
"!a!n!d!"
Returns: "&"
"ha,te"
Returns: "h8"
"a a"
Returns: "a a"
"a!n!d"
Returns: "&"
" yo,u are fima "
Returns: " U are fima "
"and and you you you"
Returns: "& & U U U"
"at "
Returns: "@ "
"a?.,nd"
Returns: "&"
"a z"
Returns: "a z"
"!!!"
Returns: ""
"THIS IS A TEST CHALLENGE....!!!!"
Returns: "this is a test challenge"