Results 1 to 3 of 3
Thread: Please for the love of god help
- 03-11-2010, 05:32 AM #1
Member
- Join Date
- Mar 2010
- Posts
- 78
- Rep Power
- 0
- 03-11-2010, 07:54 AM #2
what do you mean
what do you mean
please chaeck your labtoo.java
is this correct for you
- 03-11-2010, 07:54 AM #3
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();
}
}*/
}
Similar Threads
-
In love with gui
By fresh83 in forum New To JavaReplies: 4Last Post: 12-27-2009, 09:35 AM -
For the people who love Calculus
By tim in forum Forum LobbyReplies: 9Last Post: 12-01-2009, 12:53 PM -
I'm falling in love with java...
By IndioDoido in forum IntroductionsReplies: 2Last Post: 08-30-2009, 03:38 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks