2007 Canadian Computing Competition, Stage 1

Problem J2: I Speak TXTMSG

Text messaging using a cell phone is popular among teenagers. The messages can appear peculiar because short forms and symbols are used to abbreviate messages and hence reduce typing.

For example, “LOL” means “laughing out loud” and “:-)” is called an emoticon which looks like a happy face (on its side) and it indicates chuckling. This is all quite a mystery to some adults.

Write a program that will continually input a short form and output the translation for an adult using the following translation table:

Short Form Translation
CU see you
:-) I'm happy
:-( I'm unhappy
;-) wink
:-P stick out my tongue
(~.~) sleepy
TA totally awesome
CCC Canadian Computing Competition
CUZ because
TY thank-you
YW you're welcome
TTYL talk to you later


The user will enter text to be translated one line at a time. When the short form “TTYL” is entered, the program ends. Users may enter text that is found in the translation table, or they may enter other words. All entered text will be symbols or upper case letters. There will be no spaces and no quotation marks.


The program will output text immediately after each line of input. If the input is one of the phrases in the translation table, the output will be the translation; if the input does not appear in the table, the output will be the original word. The translation of the last short form entered “TTYL” should be output.

Sample Input


Sample Output

Canadian Computing Competition
I'm happy
talk to you later

All Submissions
Best Solutions

Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Sep 30, 2008

Problem Types: [Show]

Languages Allowed:

Comments (Search)

Anyone help me whats wrong in my code

Read the problem statement. Does your code even work on the Sample Input when you run it yourself? If not, fix that before asking for help.

Yeah its working properly with the sample input.

I promise you that your latest submission does not. Look more carefully.

Just for my own clarification, how do you make a program continue to run until a specific input is obtained? I don't exactly understand how to do that.

You're really close with what you have now!

Instead, you should take your while statement and move it up to the top.

That way, the program will do this:

While there is still input left

Is this the input that I should stop at?

If so, break

Otherwise keep going with this new input

That's why there are while loops.

conversion array!

Now, whenever I type in TTYL, it just stops, but does not print out the translation. What do I do??????

Well, what exactly does break do? When does it make sense to break?

use the do while loop