Results 1 to 3 of 3
  1. #1
    Meta is offline Member
    Join Date
    Mar 2010
    Posts
    78
    Rep Power
    0

    Default Please for the love of god help

    nvm. i fixed it i think
    Last edited by Meta; 03-11-2010 at 06:46 AM.

  2. #2
    javastuden's Avatar
    javastuden is offline Senior Member
    Join Date
    Nov 2009
    Posts
    162
    Rep Power
    5

    Default what do you mean

    what do you mean
    please chaeck your labtoo.java
    is this correct for you

  3. #3
    javastuden's Avatar
    javastuden is offline Senior Member
    Join Date
    Nov 2009
    Posts
    162
    Rep Power
    5

    Default

    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

  1. In love with gui
    By fresh83 in forum New To Java
    Replies: 4
    Last Post: 12-27-2009, 10:35 AM
  2. For the people who love Calculus
    By tim in forum Forum Lobby
    Replies: 9
    Last Post: 12-01-2009, 01:53 PM
  3. I'm falling in love with java...
    By IndioDoido in forum Introductions
    Replies: 2
    Last Post: 08-30-2009, 04:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •