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

    Default I need DIRE DIRE HELP

    i cant run any program, becuase i think the path is set wrong, but i did wat im supposed to. i copied the address of the bin folder of the jdk folder, and i put it in the CLASSPATH under environment variables. and it still doesnt work. i cant check my code, and this is due tomorrow. i need major help. this is what im asking:

    ~does it run correctly?
    ~i need to make it so the user can enter words until they want to stop, i guess by typing -1 or sumthing, but idk how to do that. heres my code. i need help please. im crying.


    import java.util.Scanner;

    public class labtoo
    {
    public static void main(String[] args)
    {
    String[] EnglishArray = {"cat", "dog", "house", "table", "turtle", "water", "yellow", "zoo"};
    String[] SpanishArray = {"gato", "perro", "casa", "mesa", "tortuga", "agua", "amarillo", "zoologico"};
    Scanner keyboard = new Scanner(System.in);
    int languageSelect = 0;
    String wordToSearch = null;
    boolean found = false;

    System.out.println("Would you like to start in english(Enter 1) or in spanish(enter 2)?");
    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 == 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> EnglishArray.length; i++)
    {
    if (wordToSearch == EnglishArray[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();
    }
    }
    }

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

    Default

    hi,some probelms in programing see the difference
    import java.util.Scanner;

    public class labtoo
    {
    public static void main(String[] args)
    {
    String[] EnglishArray = {"cat", "dog", "house", "table", "turtle", "water", "yellow", "zoo"};
    String[] SpanishArray = {"gato", "perro", "casa", "mesa", "tortuga", "agua", "amarillo", "zoologico"};
    Scanner keyboard = new Scanner(System.in);
    int languageSelect = 0;
    String wordToSearch = null;
    boolean found = false;

    System.out.println("Would you like to start in english(Enter 1) or in spanish(enter 2)?");
    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();
    }
    }
    }
    if your path is not set yet then it won't work properly

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

    Default

    dfijoadspfjdpf
    Last edited by Meta; 03-11-2010 at 05:34 AM.

  4. #4
    Meta is offline Member
    Join Date
    Mar 2010
    Posts
    78
    Rep Power
    0

    Default

    is it easy to change from if statements to methods for the translations?

  5. #5
    Meta is offline Member
    Join Date
    Mar 2010
    Posts
    78
    Rep Power
    0

    Default

    plz!!! how do i loop this until the user says STOP! :( i need to go to bed. this is duei n morning. im crying

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,005
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Meta View Post
    plz!!! how do i loop this until the user says STOP! :( i need to go to bed. this is duei n morning. im crying
    There are two environment variables that need to be set: your PATH variable has to point to the bin directory of your JDK; this is not a Java issue but an OS issue: it needs to find the executable files javac.exe and java(w).exe.

    The other variable is CLASSPATH; it's a list of directories where your jvm has to look for .class and/or .jar files. You can also set this variable by using -classpath <dirlist> on the command line of any java utility (javac, java, etc).

    kind regards,

    Jos

Similar Threads

  1. I Am In Dire Need Of Help
    By diptarka.ray in forum Advanced Java
    Replies: 2
    Last Post: 10-20-2008, 09:39 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
  •