Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: HELP PLEASE!

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question HELP PLEASE!

    I hava a problem with this program: Ideone.com | Online Java Compiler & Debugging Tool

    (Sorry about the notes in hebrew)

    When I active this programm I write one of the lines on the .txt file and it write to me:
    "Computer: Haven't enough data...".
    I don't understand why the programm don't responds to the input.

    HELP PLEASE!!!!

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: HELP PLEASE!

    Please post the code that you are having problems with on the forum.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: HELP PLEASE!

    This is the code:

    import java.io.IOException;
    import java.util.Scanner;
    public class Main {

    /**
    * @param args
    */
    public static void main(String[] args) throws IOException {
    // TODO Auto-generated method stub
    Scanner user_Input = new Scanner(System.in);
    String file_name = "C:/Program Files/VirtualTalk/projectxt.txt";
    String commend;
    int i;
    boolean found = false;
    while (true) {
    found = false;
    System.out.print("User: ");
    commend = user_Input.next();
    System.out.println(commend);
    try {
    ReadFile file = new ReadFile(file_name);
    String[] aryLines = file.OpenFile();

    for (i = 0; (i < aryLines.length) && (found == false); i++) {
    found = commend.equals(aryLines[i]);
    if (found == true) {
    System.out.println("Computer: " + aryLines[i++]);
    }
    }
    if (found == false) {
    System.out.println("Computer: Haven't enough data...");
    }

    } catch (IOException e) {
    System.out.println(e.getMessage());
    }
    }
    }

    }

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: HELP PLEASE!

    Please use code tags, not quote tags for the code to preserve formatting. The posted code has lost all formatting.

    why the programm don't responds to the input.
    What is the program supposed to do? Can you describe the steps it is supposed to take and what the output from the program should be?
    How does the program get input?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Sep 2012
    Posts
    26
    My Mood
    Bored
    Thanks
    6
    Thanked 5 Times in 4 Posts

    Default Re: HELP PLEASE!

    I'm going to post his code properly formatted, only because I'm not sure if english is his first language, given his hebrew comments and the structure of his OP (No offense meant!)
    import java.io.IOException;
    import java.util.Scanner;
    public class Main {
     
            /**
             * @param args
             */
            public static void main(String[] args) throws IOException {
                    // TODO Auto-generated method stub
                    Scanner user_Input = new Scanner(System.in); 
                    String file_name = "C:/Program Files/VirtualTalk/projectxt.txt";  // מיקום הטקסט
                    String commend;
                    int i;
                    boolean found = false;
                    while (true) {  // לולאה ראשית
                            found = false;
                            System.out.print("User: ");
                            commend = user_Input.next();  // קריאת פקודות מהמשתמש
                            System.out.println(commend);
                            try {
                                    ReadFile file = new ReadFile(file_name);
                                    String[] aryLines = file.OpenFile();
     
                                    for (i = 0; (i < aryLines.length) && (found == false); i++) {
                                            found = commend.equals(aryLines[i]);
                                            if (found == true) {
                                                    System.out.println("Computer: " + aryLines[i++]);
                                            }
                                    }
                                    if (found == false) {
                                            System.out.println("Computer: Haven't enough data..."); 
                                    }
     
                            } catch (IOException e) {
                                    System.out.println(e.getMessage());
                            }
                    }
            }
     
    }

  6. The Following 2 Users Say Thank You to ChicoTheMan94 For This Useful Post:

    jps (September 23rd, 2012), Norm (September 23rd, 2012)