Write a program that simulates a translation dictionary Your
Write a program that simulates a translation dictionary. Your program must be able to support any number of words and multiple languages. Input can be read in from a text file, where each line is in the format: :: For example, a few lines might be: pollo:spanish:chicken hund:german:dog perro:spanish:dog A menu should be presented allowing the user to type in a word in English and then be presented with the word in another language. In addition, the user should have an option to enter a foreign word to learn the English meaning. In the comments for each of your methods, indicate the time complexity of your algorithm. using java
Solution
import java.io.*;
import java.util.*;
class Dictionary1Generator {
static Vector words = new Vector();
static void loadWords() {
try {
BufferedReader f =
new BufferedReader(new FileReader(\"words.txt\"));
String word = null;
while ((word = f.readLine())!=null) {
words.addElement(word);
}
} catch (Exception e) {
System.err.println(\"Unable to read words from words.txt\");
}
}
static public void main(String[] args) {
loadWords();
System.out.println(\"class Dictionary1 {\ \");
System.out.println(\" String words = {\");
for (int j=0; j<words.size(); ++j) {
System.out.println(\" \\\"\"+words.elementAt(j)+\"\\\",\");
}
System.out.println(\" };\");
System.out.println(\"\ \");
System.out.println(\" public boolean isWord(String w) {\");
System.out.println(\" for (int j=0; j<words.length; ++j) {\");
System.out.println(\" if (w.equals(words[j])) {\");
System.out.println(\" return true;\");
System.out.println(\" }\");
System.out.println(\" }\");
System.out.println(\" return false;\");
System.out.println(\" }\");
System.out.println(\"}\");
}
}

