matching user input to data in array
807607Nov 14 2006 — edited Nov 14 2006Ok here is the dilema. I have a text file that is loaded into java and stored in a 2-d array. There is an english version of a word, and then the translated english word. I want to have the user enter a sentence that is stored as a string. If there is a word that matches a word in the array, it is to replace it with the translated word. thinking something along these plans which i got from class but have no clue how to code it .
Translate method ( pass it the 2-d array and user input)
---Create a string tokenizer with the english (which i have no idea how to do)
---use hasMoreTokens() for while loop
i. get next token
ii. match against zeroth column in 2D array
iii. if match, print column 1
iv. if no match, print the english word
Im having the most problem with creating a string tokenizer and then how i could match it up with the zeroth column of the 2D array, which is where the english words are kept, and the translated ones in column 1.
any examples of how i could do this?