The objective of this programming assignment is to become familiar with C++ file I/O.
For this assignment, you may work alone or in groups of two. If you work as a pair, only submit one solution. Make sure that the documentation mentions both students.
The goal of this assignment is to create a simple word translator using the English-Spanish and German-English dictionaries provided below. english_spanish.txt english_german.txt These ASCII files must be in the same directory as your source code.
If you choose to work alone you only need to create the English-Spanish and Spanish-English translator. The translator should present a menu to the user to either translate from English to Spanish or from Spanish to English. The translator should receive an input word from the user and translate it to the corresponding language for any word in the language dictionary. If a word is entered that does not exist in the dictionary, then the translator should display a message that it does not know this word.
If you choose to work in pairs, you must create both English-Spanish/Spanish-English and English-German/German-English translators and provide extra menu options for the added functionality. Notice that the two dictionaries do not have all the same words. For example, "alligator" is in the English-German dictionary but not in the Spanish-German dictionary. Also, the two files are also not of the same length.
10 POINT BONUS: For extra credit, use both files together to create a Spanish-German/German-Spanish translator. Note: Since the two files do not contain exactly the same words, you may not be able to translate from Spanish to English and then from English to German for all words.
You must use parallel arrays to keep track of the dictionaries. Using two arrays, read an English word into an array and then the translation into another array at the same index. To translate an English word, find the index of the word in the English word array and use this index to access the translated word array.
If you are working in pairs, you will need two English word arrays. One for English-Spanish translation and another for English-German translation.
The parallel arrays must be of string type. You must read each line of the dictionary into string variables and place these in the parallel arrays. Since each line of the dictionary contains exactly three words (e.g. cat el gato) we will need to store "cat" in the English array and "el gato" in the Spanish array. There are two ways to accomplish this.
First, we can read "cat", "el" and "gato" in as separate string variables. To store "el gato" (one string) into the Spanish array we will need to concatenate the strings "el", " ", and "gato".
Second, we can read "cat" and "el gato" into two string variables. Start by reading "cat" into a string variable and then call getline to read the rest of the line ("el gato").
Work incrementally; implement one step at a time. It may help to start with a language dictionary that only contains 3 or 4 lines. Once you get that working, try the whole file.
Test your program to check that it operates correctly for all of the requirements listed above. Also check for the error handling capabilities of the code. Make sure to include valid input and invalid input in your test samples that you turn in. Also make sure to print the output for a case where the word is not found in the dictionary.
When you have completed your C++ program, write a short report (less than one page long) describing what the objectives were, what you did, and the status of the program. Does it work properly for all test cases? Are there any known problems? Save this report in a separate text file to be submitted electronically.
If you work in pairs, only submit one version using the ID of one of the pair. The comments in the code and the documentation should clearly name the partner so both students get credit.
In this class, we will be using electronic project submission to make sure that all students hand their programming projects and labs on time, and to perform automatic analysis of all programs that are submitted. When you have completed the tasks above go to the class web site to "upload" your documentation and testing document (pdf, doc, or txt file), and your C++ program (cpp or txt file).
The dates on your electronic submission will be used to verify that you met the due date above. All late projects will receive reduced credit:
You will receive partial credit for all programs that compile even if they do not meet all program requirements, so handing projects in on time is highly recommended.