Saturday, January 14, 2012

HomeWork 1: Tweet to Leet

For the first homework you will implement a simple twitter message to Leet translator. You will need to use the String class (Chapter 2) and if-else statements (Chapter 3) which we will cover the week of Jan. 16. Your program will ask the user for a tweet, change all the characters in the tweet to lower case, then it will print out that tweet but translated to Leet using the substitutions below.

Replace thiswith this

The message can also contain up to one hash tag. A hash tag starts with a # then some non-space characters, then ends with a space. So #hello is a hashtag but # by itself is just a #. Your program will find and print out this hash tag, if there. Also, the hashtag should not be changed into Leet. You can assume that there is at most 1 hash mark in the message the user types in.

Finally, you will print out the length of the tweet and if it is more than 140 characters you will print out an error message.

Below are some examples.

I will translate your tweet to Leet.
Enter your tweet:Hi there! Just a simple tweet to get started.
No Hashtag found.
Translation: hi 7h3r3! ju57 4 5imp13 7w337 70 637 574r73d. 
Message has 46 characters.

I will translate your tweet to Leet.
Enter your tweet:This one has a #hashtag Notice how it remains the same in the final message.
Hashtag: #hashtag
Translation: 7hi5 0n3 h45 4 #hashtag n07ic3 h0w i7 r3m4in5 7h3 54m3 in 7h3 fin41 m355463. 
Message has 77 characters.

I will translate your tweet to Leet.
Enter your tweet:The empty # is not a hashtag and should be left alone.
No Hashtag found.
Translation: 7h3 3mp7y # i5 n07 4 h45h746 & 5h0u1d 83 13f7 410n3. 
Message has 53 characters.

I will translate your tweet to Leet.
Enter your tweet:If you type a really long tweet then the program will still translate it but will give you an error because there is a 140 character limit #145rocks
Hashtag: #145rocks
Translation: if y0u 7yp3 4 r3411y 10n6 7w337 7h3n 7h3 pr06r4m wi11 57i11 7r4n51473 i7 8u7 wi11 6iv3 y0u 4n 3rr0r 83c4u53 7h3r3 i5 4 140 ch4r4c73r 1imi7 #145rocks 
Message has 149 characters.
ERROR: Too big to tweet.

Remember that work on pairs if at all possible.

This homework is due Monday January 23 @noon in the

No comments: