• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The MathQuiz file doesnt seem to run i dont know why

 
Tim Lai
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could there be a problem with how i called the randomgenerator. thanks

-Tim




 
Campbell Ritchie
Sheriff
Posts: 48381
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I have added code tags, which you should always use; you can see how much better it looks now. I have also removed some of the excess blank lines. You should use spaces for indenting, not tabs.
I can’t tell whether you called the random generator right, because these ACM programs use their own API which I don’t have access to and I am not familiar with.
What happens? Does the program compile at all? Do you get an Exception at runtime.
Try replacing the random generator with a java.util.Random object.
There is something wrong about an int for sign. Try a boolean
boolean negative = myRandom.next...();
But that is going to cause difficulty when you print it out; you can print 1/2 or true/false, but from what I can see you won’t get +/−.
You can similarly get “random” ints from the Random object, but read the documentation carefully to see their range.
I would use a Scanner for the keyboard input, myself.

Why are you implementing Runnable for a single‑threaded application? And if the answer is, “that is how the app is structured,” find out why the app is structured like that. How are you calling that run() method? Are you doing something in your main method like new Thread(new MathQuiz()).start();? I tried that and it worked first time.
 
Tim Lai
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the adjustments. well the program says there are multiple markers at the line of the instance of the randomgenerator.

it says to debug the current instruction pointer
and
watchpoint:MathQuiz[access modification] - rgen


i have already fixed the sign issue
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic