View Full Version : Basic maths game help, division.

03-06-2013, 01:43 AM
Hi all,

Just recently started programming so apologies if this is noobish.

I am making a basic maths game for a project and are just having a few problems with it. I have four questions, multiply, add, division and minus and all the numbers are randomly generated. However I am trying to get my head round how I could make the division numbers only even, or numbers that won't leave decimals remaining in the answer, 10 divided by 7 = 1.428 etc.

This is my code for the division problem. Divide one and divide 2 are the two separate numbers that will appear to be divided. I've made it so the first number is always larger than the first one, but now are trying to avoid these awkward numbers that cause remainders.

// Fill in the division problem.
divide1 = randomizer.Next(5, 11);
divide2 = randomizer.Next(2, 4);
DivLLabel.Text = divide1.ToString();
DivRLabel.Text = divide2.ToString();
sum3.Value = 0;

Thanks in advance.

03-06-2013, 01:58 AM
Simplest solution:

Generate two random numbers.

The first number for the divide will be the two random numbers multiplied together, the second number for the divide will be one of the random numbers - so the answer will be the other random number.

03-06-2013, 02:20 AM
Great thanks! Appreciate it.