nvm. i fixed it i think
Printable View
nvm. i fixed it i think
what do you mean
please chaeck your labtoo.java
is this correct for you
sorry the attachment is no there
import java.io.*;
public class labtoo
{
public static void main(String[] args)throws Exception
{
String[] EnglishArray = {"cat", "dog", "house", "table", "turtle", "water", "yellow", "zoo"};
String[] SpanishArray = {"gato", "perro", "casa", "mesa", "tortuga", "agua", "amarillo", "zoologico"};
String wordToSearch = null;
int choice=0,pos=0,flag=0;
System.out.println ("Enter your choice");
System.out.println ("1:-convert to English");
System.out.println ("2-:convert to Spanish");
System.out.println ("3-:Exit/Stop");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
do{
System.out.println ("Enter your choice");
choice=Integer.parseInt(br.readLine());
switch (choice) {
case 1:
System.out.println("What word would you like to find? Example: 'cat' ");
wordToSearch = br.readLine();
for(String dd:EnglishArray){
if(dd.equalsIgnoreCase(wordToSearch))
{pos=dd.indexOf(wordToSearch);}else{flag=1;}
}
if(flag==0)
System.out.println("The Spanish equivalent of " + wordToSearch + " is " + SpanishArray[pos]);
else{System.out.println("The Spanish equivalent of " + wordToSearch + " is not found in dictonary " );}
break;
case 2:
System.out.println("What word would you like to find? Example: 'perro'? ");
wordToSearch = br.readLine();
for(String dd:SpanishArray){
if(dd.equalsIgnoreCase(wordToSearch))
{pos=dd.indexOf(wordToSearch);}else{flag=1;}
}
if(flag==0)
System.out.println("The English equivalent of " + wordToSearch + " is " + EnglishArray[pos]);
else{System.out.println("The English equivalent of " + wordToSearch + " is not found in dictonary" );}
break;
case 3:{System.out.println("Exiting . . .");
System.exit(0);}
default :
System.out.println ("please select a valid number");
}
}while(choice!=3);
}
protected static void selector(){
System.out.println ("select one from the options");
System.out.println ("1:-convert to English");
System.out.println ("2-:convert to Spanish");
System.out.println ("3-:Repeat");
System.out.println ("4-:Exit/Stop");
}
/*public static void languages(){
boolean found = false;
String wordToSearch = null;
System.out.println("Would you like to start in english(Enter 1) or in spanish(enter 2)?");
Scanner keyboard = new Scanner(System.in);
int languageSelect = 0;
languageSelect = keyboard.nextInt();
if (languageSelect == 1)
{
//while (found != true)
//{
System.out.println("What word would you like to find? Example: 'cat' ");
wordToSearch = keyboard.next();
for (int i = 0; i<EnglishArray.length; i++)
{
if (wordToSearch.equalsIgnoreCase(EnglishArray[i]))
{
System.out.println("The Spanish equivalent of " + wordToSearch + " is " + SpanishArray[i]);
//found = true;
}
}
//}
}
else if (languageSelect == 2)
{
//while (found != true)
//{
System.out.println("What word would you like to find? Example: 'perro'? ");
wordToSearch = keyboard.next();
for (int i = 0; i<SpanishArray.length; i++)
{
if (wordToSearch.equalsIgnoreCase(SpanishArray[i]))
{
System.out.println("The English equivalent of " + wordToSearch + " is " + EnglishArray[i]);
found = true;
}
}
//}
}
else
{
System.out.println("Please Enter either 1 for English or 2 for Spanish");
languageSelect = keyboard.nextInt();
}
}*/
}