• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

The MathQuiz file doesnt seem to run i dont know why

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
could there be a problem with how i called the randomgenerator. thanks

-Tim




 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic