Results 1 to 4 of 4
  1. #1
    NixasMuraki is offline Member
    Join Date
    Jan 2011
    Posts
    11
    Rep Power
    0

    Default BlueJ compiles with no errors...but doesn't run

    I know I posted something about this code before because of a simple problem, but now it says that I have no syntax errors, but it compiles forever and nothing ever happens...Does anyone know why this might be happening? Do you think that if I put the same code into an eclipse project that it would help? Please answer both questions because my Eclipse has run away from me and is lost on my comp and I really would rather not using it... (I'm aware of my run on sentences, but I don't care)

    import java.util.*;
    import java.util.Random.*;
    public class HA2
    {

    public static void main(String[] args)
    {

    //let R be any real rational number
    //if 0=0 infinite solutions if 0=anything else no solution
    //first problem will be Infinite or No Solutions with Elimination
    Random generator=new Random();//use nextGaussian() to create random positive and negative ints
    Scanner ynanswer=new Scanner(System.in);
    String answer=ynanswer.nextLine();

    double R1=generator.nextGaussian();//makes a random real number
    double R2=generator.nextGaussian();
    double R3=generator.nextGaussian();
    double R4=generator.nextGaussian();
    double R5=generator.nextGaussian();
    double R6=generator.nextGaussian();

    R1=Math.round(100*R1)/(100);
    R2=Math.round(100*R2)/(100);
    R3=Math.round(100*R3)/(100);
    R4=Math.round(100*R4)/(100);
    R5=Math.round(100*R5)/(100);
    R6=Math.round(100*R6)/(100);

    System.out.println("Use elimination to determine whether this will have infinite or no solutions\n " +R1+"x+"+R2+"y="+R3+"\n" +R4+"x+"+R5+"y="+R6+"\nWould you like to see the solution? Type in yes or no.");
    if(answer.equalsIgnoreCase("yes"))
    { if(((R1/R4)==(R2/R5))&&((R2/R5)==(R3/R6)))
    {
    System.out.println("This problem has infinite solutions");
    }
    else if(((R1/R4)==(R2/R5))&&((R2/R5)!=(R3/R6)))
    {
    System.out.println("This problem has no solution");
    }
    }
    else if(answer.equalsIgnoreCase("no"))
    {
    System.out.println("Very well then, I suppose you can find the answer yourself...ingrate");
    }
    }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    Java Code:
    Scanner ynanswer=new Scanner(System.in);
    String answer=ynanswer.nextLine();
    Could it be waiting for some input?
    Stick a System.out.println("some text") before this.

  3. #3
    NixasMuraki is offline Member
    Join Date
    Jan 2011
    Posts
    11
    Rep Power
    0

    Default

    *facepalm* oh my god. I feel so incredibly stupid

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    These sort of things never go away...we always do dim things.
    That's why we have work colleagues...:)

    I spent an hour last week pointing at the wrong database...

Similar Threads

  1. compiles but I get errors, need help
    By jjth39347 in forum New To Java
    Replies: 3
    Last Post: 03-06-2011, 08:29 PM
  2. Replies: 6
    Last Post: 02-08-2011, 02:29 AM
  3. Replies: 4
    Last Post: 01-04-2011, 12:36 AM
  4. Replies: 3
    Last Post: 03-08-2009, 01:51 AM
  5. Errors driving me crazy! although compiles fine
    By irishsea2828 in forum New To Java
    Replies: 1
    Last Post: 04-08-2008, 03:23 PM

Posting Permissions

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