Dictionary menu thing? Due tomorrow x.x

Ok so my professor wants me to create a menu driven program that translates english to spanish and vice versa. He gave us two files which were the spanish word file and the english word file which consist of 125 words each. He said the user should be able to type in a word and it would say if the word is in the file or not and display its translation. Also, this is due tonight...i know, i know, the procrastination. But if you would be so kind to help.

Last edited on
Ok so im still confused on how to compare the user input... Say for example the user types the word "dog". How would i check to see if the word "dog" is even in the eng.txt folder and then if it is how would i display the corresponding word from the span.txt folder? This is what i have so far.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
int main()
{
   ifstream Efile,Sfile;

   string eNames[125], sNames[125];
   int i, cnt;
   char junk;
   int option;
   char choice;
   do{
    cout << "                                              ***Menu***" << endl;
    cout << "                                        1.Display a dictionary" << endl;
    cout << "                                        2.Translate from English to Spanish" << endl;
    cout << "                                        3.Translate from Spanish to English" << endl;
    cout << "                                        4.Exit Program" << endl;
    cin >> option;

   switch (option)
   {
   case 1:
   Efile.open("eng.txt");
   Sfile.open("span.txt");
   i = 0;
   while (Efile >> eNames[i])
   {
      i++;
   }
   cnt = i;
   i = 0;
   cout << "                                       This english dictionary consist of " << cnt << " words\n";

   while (Sfile >> sNames[i])
   {
      i++;
   }
   cout << "                                       There are also " << i << " Spanish words\n";


   Efile.close();
   Sfile.close();

   for(int k=0; k < cnt; k++)
   {
        cout << k+1 << "                                        " << eNames[k] << " " << sNames[k] << endl;
        if ((k+1) == 20 || (k+1) == 40 || (k+1) == 60 || (k+1) == 80 || (k+1 == 100))
        {
            cout << "                                  Press Enter to display the next set of words...";
            cin.get(junk);
            cin.ignore();
            system("CLS");
        }
   }
   break;
   case 2:
    cout << "Enter the word that you would like translated to spanish" << endl;

    break;
   case 3:
    cout << "Enter the word that you would like translated to spanish" << endl;
    break;
   case 4:
    cout << "Exiting Program...Goodbye!!!" << endl;
    return 0;
    break;
   default:
    cout << "invalid entry" << endl;
   }
   cout<<"Would you like to continue? (Y/N)" << endl;
   cin >> choice;
   }while(choice == 'y' || choice == 'Y');

   cout << endl;
   return 0;
}
Normally you should read both the files at start of main.
If the user chooses english to spanish then you read the english word, for example dog.
If you find the word in the english array you display the corresponding spanish word from the spanish array, otherwise you show a message "not in dictionary"
Registered users can post here. Sign in or register to post.