Results 1 to 3 of 3
  1. #1
    luisx86 is offline Member
    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0

    Question Algorithm problem.

    hello people,
    as a task for this week I have to create an algorithm to compare each line of a document with another.
    I have created my algorithm but apparently I have a problem with it.
    I would appriciate if anyone can tell me whats wrong with it, thanks.
    codes:

    public class Project_2{
    public static void main(String [] args)throws IOException{
    BufferedReader br1 = new BufferedReader(new FileReader("Ravi.txt"));
    BufferedReader br2 = new BufferedReader(new FileReader("Ravi_2.txt"));

    int y = 0;
    String x;


    int lineSimilar1 = 0;
    int lineSimilar2 = 0;
    String line1 = br1.readLine();

    while((br1.readLine() != null) && (br2.readLine() != null)){
    System.out.println("hello it works");
    if(line1.equals(br2.readLine())){
    System.out.println("hello Im working");
    y++;
    lineSimilar1++;

    System.out.println(""+y);
    }
    }
    String line2 = br2.readLine();
    while((br1.readLine() != null) && (br2.readLine() != null)){
    if(line2.equals(br1.readLine())){ //(x > br.readLine()) && (x > br1.readLine())
    y++;
    lineSimilar2++;

    System.out.println(""+y);
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: Algorithm problem.

    Moved from Advanced Java.

    Please go through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Algorithm problem.

    Quote Originally Posted by luisx86 View Post
    hello people,
    as a task for this week I have to create an algorithm to compare each line of a document with another.
    I have created my algorithm but apparently I have a problem with it.
    I would appriciate if anyone can tell me whats wrong with it, thanks.
    You might first want to tell us how it's not working. Next you'll want to wrap your code in code tags so that it retains its formatting allowing us to be able to read it.

Similar Threads

  1. What is the best search algorithm for this problem?
    By daiviko in forum New To Java
    Replies: 4
    Last Post: 07-03-2012, 09:44 PM
  2. An algorithm problem
    By bMorgan in forum New To Java
    Replies: 1
    Last Post: 01-27-2011, 09:53 AM
  3. Algorithm Problem
    By Aggy in forum New To Java
    Replies: 4
    Last Post: 01-21-2010, 11:00 PM
  4. Problem with algorithm
    By Albert in forum AWT / Swing
    Replies: 1
    Last Post: 07-13-2007, 03:31 PM
  5. Algorithm problem
    By Marcus in forum Advanced Java
    Replies: 2
    Last Post: 07-01-2007, 01:37 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
  •