Results 1 to 4 of 4
- 06-01-2011, 06:13 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 11
- Rep Power
- 0
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");
}
}
}
- 06-01-2011, 06:21 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,457
- Rep Power
- 16
Could it be waiting for some input?Java Code:Scanner ynanswer=new Scanner(System.in); String answer=ynanswer.nextLine();
Stick a System.out.println("some text") before this.
- 06-01-2011, 06:24 PM #3
Member
- Join Date
- Jan 2011
- Posts
- 11
- Rep Power
- 0
*facepalm* oh my god. I feel so incredibly stupid
- 06-01-2011, 06:35 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,457
- Rep Power
- 16
Similar Threads
-
compiles but I get errors, need help
By jjth39347 in forum New To JavaReplies: 3Last Post: 03-06-2011, 08:29 PM -
setBounds not working (no errors; runs and compiles fine)
By cc11rocks in forum AWT / SwingReplies: 6Last Post: 02-08-2011, 02:29 AM -
First Java Program-Compile Errors (errors are posted)-simple GUI
By cc11rocks in forum AWT / SwingReplies: 4Last Post: 01-04-2011, 12:36 AM -
What is the difference between Semantic Errors and Logical Errors?
By tlau3128 in forum New To JavaReplies: 3Last Post: 03-08-2009, 01:51 AM -
Errors driving me crazy! although compiles fine
By irishsea2828 in forum New To JavaReplies: 1Last Post: 04-08-2008, 03:23 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks