im making a balloon pop math game and I need random questions and answers to come up on the balloons. how would I do this while always having the correct answer on the screen??
Answers are numbers i guess?
get a random number by getRandomNumber(x,c) and display them, those are the random numbers.
For the solution, just make 2 variables, for the question, for example 4 and 7, the question is what is 4*7.
The first number, 4 is x and the 7 is y
Then x*y=c and display c
This should work if theres only one calculation method is used, eg only add or only substract etc.
If you want to use all of them, you'd have to have a method, that tells you which one, but i dont know how to that.
Try doing it, and insert your code here, so the others can help you better ;)
@xFabi, please review the documentation of the Greenfoot class method 'getRandomNumber' (it only takes one int parameter).
@kylecompton31, there are a multitude of ways to make it so the answer is always on the screen. World wrapping (relocating the balloons as they go off one edge to a random location on the opposite edge) is one way, and probably the easiest way.
x,c wasnt actually meant to be values, i just took them to show, that you have to input numbers there :D
Edit: ah thats what you meant nvm, i thought you could also define a minimum