Lab Assignment 3
CS202, Summer 2006

Please upload your source code files using CSNS. Note that file uploading will be disabled automatically after the lab ends, so please turn in your work on time.

1.(10pt) Write a Java application that encodes English-language sentences into pig Latin. Pig Latin is a form of coded language. There are many different ways to form pig Latin sentences. For simplicity, use the following algorithm: 

To form a pig Latin sentence from an English-language sentence, first tokenize the sentence into words. To translate an English word into a pig Latin word, place the first letter of the English word at the end of the word and add the letters "ay". Thus, the word "jump" becomes "umpjay", the word "the" becomes "hetay", and the word "computer" becomes "omputercay". Blanks between words remain as blanks.

Use Scanner to read a sentence from user input. You may assume that the sentence consists of words separated by blanks, and there are no punctuation marks. Output the sentence where each word is converted into pig Latin.

2.(10pt)  Write a Java application that reads a telephone number from input as a string in the form (555) 555-5555, and outputs the phone number in the following format:

Area code: 555
Phone number: 5555555