PDA

View Full Version : Need help with a program


mawnstah
10-21-2011, 11:16 AM
Ok, I want to randomly generate 2 numbers then ask the user what is the answer, please help I'm so lost..

DensetsuNoKaboom
10-22-2011, 12:38 PM
Ok, I want to randomly generate 2 numbers then ask the user what is the answer, please help I'm so lost..

If you want a number randomly generated, make a number variable and make a method telling it to set itself to a random number; there should be a "random number" function under the world's functions.

Ask the user what is the answer? The answer to what?

Powerhouse64
11-04-2011, 05:38 PM
If you use the random number generator, it does generate a random number, but it includes decimal points. If you want to make it a bit easier on the user (I assume they're trying to guess the two numbers, or the product) have the random number be multiplied by 1. This prevents you from getting values such as 1.0 which Alice interprets as different from 1 (this caused some problems with my class, as we tried to tally up the number of randomly generated numbers 1-6 and we got 1.0's represented as a different value). Basically, put in the random number generator into the two places in your function that you need to create within your method, then multiply both random numbers by 1 to get 1-6 as opposed to 1.0-6.0 which Alice considers different numbers. (If Alice generated a 1.0 and the user guessed that the number was 1, Alice would consider them wrong, because of the fact that Alice does not understand that 1.0 and 1 are the same values)

Hope my paragraph helps!:D

-Powerhouse64