Homework 5
CS203, Spring 2006


Due: Saturday, June 3

Please upload your source code and other files using CSNS. Note that file uploading will be disabled automatically after 11:59PM of the due date, so please turn in your work on time.

This is an extra credit assignment.

In this assignment, you are going to writes a Java program Translator.java, which translates English words into Spanish using an English-Spanish Dictionary File, which can be downloaed from The Internet Dictionary Project.

(+40pt) Translator.java first reads the dictionary file, and store all the entries in a HashMap<String,String>. You must use the HashMap<K,V> class you developed in Homework 4; otherwise you will not receive any credit. The program then prompts the user to enter an English word, and uses the input word to look up the dictionary stored in the hash map. If the word is found in the dictionary, the program displays the Spanish translation of the word; otherwise it displays a message "The word is not found in my dictionary". The program should repeat the process until the user enters "\q" or "\e", which terminates the program. A typical session of using Translator.java may looks like the following:

C:\HW5> java Translator
Please enter an English word:
hello
The Spanish translation is:
hola, que tal
Please enter an English word:
xyz
Sorry, the word is not found in my dictionary.
Please enter an English word:
\q
Thanks for using the translator.
C:\HW5>

(+40pt)  Build a graphical user interface (GUI) for the translator program.