mardi 22 mars 2016

How to make math questions with whole number solutions?

I'm trying to make a simple program that makes division math tasks, and then checks if the user typed in the right answer to the calculation. Here are the basic code:

        //Get the 2 random numbers
        number1 = rand.Next(999) + 1;
        number2 = rand.Next(99) + 1;

        //Setup Calculation
        calculation = number1 + " / " + number2 + " =";

The problem is that a calculation like this: 699 / 58 = 12.05172413. It has too many digits. I need the program to only make calculations where the answer is a whole number.

My first idea is to make the random numbers be 10,20,30,40,50... But I'm not sure if you can specify the random numbers like that?




Aucun commentaire:

Enregistrer un commentaire