Exemple #1
0
        public static OrdinaryFractions2 GenerateSubtraction()
        {
            OrdinaryFractions2 ret;

            do
            {
                ret.a.counter     = UniversalFunctions.Rand(3, 10);
                ret.a.denominator = UniversalFunctions.Rand(2, 10);
                ret.b.counter     = UniversalFunctions.Rand(1, 9);
                ret.b.denominator = UniversalFunctions.Rand(1, 9);
                ret._operator     = "-";

                ret.correctanswer.denominator = UniversalFunctions.LCM(ret.a.denominator, ret.b.denominator);
                int tmpCounterA = ret.a.counter * (ret.correctanswer.denominator / ret.a.denominator);
                int tmpCounterB = ret.b.counter * (ret.correctanswer.denominator / ret.b.denominator);

                ret.correctanswer.counter = tmpCounterA - tmpCounterB;
                if (ret.correctanswer.counter < 0)
                {
                    continue;
                }
                int tmpGCD = UniversalFunctions.GCD(ret.correctanswer.counter, ret.correctanswer.denominator);
                ret.correctanswer.counter     /= tmpGCD;
                ret.correctanswer.denominator /= tmpGCD;
            } while (ret.correctanswer.counter < 0);

            return(ret);
        }
        /// <summary>
        /// Generate Subtraction Expression (Floating Points value)
        /// </summary>
        /// <returns></returns>
        public static ValueDecimal2 GenerateSubtraction()
        {
            ValueDecimal2 ret;

            ret.a             = UniversalFunctions.RandDecimal(1, 9.5m);
            ret.b             = UniversalFunctions.RandDecimal(1, ret.a);
            ret.correctanswer = ret.a - ret.b;
            ret.displayvalue  = Convert.ToString(ret.a) + " - " + Convert.ToString(ret.b) + " =";
            return(ret);
        }
        /// <summary>
        /// Generate Addition Expression (Floating Points value)
        /// </summary>
        /// <returns></returns>
        public static ValueDecimal2 GenerateAddition()
        {
            ValueDecimal2 ret;

            ret.a             = UniversalFunctions.RandDecimal(0.1m, 9.5m);
            ret.b             = UniversalFunctions.RandDecimal(0.1m, 9.5m);
            ret.correctanswer = ret.a + ret.b;
            ret.displayvalue  = Convert.ToString(ret.a) + " + " + Convert.ToString(ret.b) + " =";
            return(ret);
        }
        /// <summary>
        /// Generate Multiplication Expression (Floating Points value)
        /// </summary>
        /// <returns></returns>
        public static ValueDecimal2 GenerateMultiplication()
        {
            ValueDecimal2 ret;

            ret.a             = UniversalFunctions.RandDecimal(1, 10, 10);
            ret.b             = UniversalFunctions.RandDecimal(1, 10, 10);
            ret.correctanswer = ret.a * ret.b;
            ret.displayvalue  = Convert.ToString(ret.a) + " * " + Convert.ToString(ret.b) + " =";
            return(ret);
        }
Exemple #5
0
        /// <summary>
        /// Generate Subtraction Expression
        /// </summary>
        /// <returns></returns>
        public static ValueInt2 GenerateSubtraction()
        {
            var ret = new ValueInt2();

            ret.a             = UniversalFunctions.Rand(1, 100);
            ret.b             = UniversalFunctions.Rand(1, ret.a);
            ret.correctanswer = ret.a - ret.b;
            ret.displayvalue  = Convert.ToString(ret.a) + " - " + Convert.ToString(ret.b) + " =";
            return(ret);
        }
Exemple #6
0
        public static OrdinaryFractions2 GenerateDivision()
        {
            OrdinaryFractions2 ret;

            ret.a.counter     = UniversalFunctions.Rand(1, 8);
            ret.a.denominator = UniversalFunctions.Rand(1, 9);
            ret.b.counter     = UniversalFunctions.Rand(1, 8);
            ret.b.denominator = UniversalFunctions.Rand(1, 9);
            ret._operator     = "\u00f7";

            ret.correctanswer.counter     = ret.a.counter * ret.b.denominator;
            ret.correctanswer.denominator = ret.a.denominator * ret.b.counter;
            int tmpGCD = UniversalFunctions.GCD(ret.correctanswer.counter, ret.correctanswer.denominator);

            ret.correctanswer.counter     /= tmpGCD;
            ret.correctanswer.denominator /= tmpGCD;

            return(ret);
        }
Exemple #7
0
        /// <summary>
        /// Return an expression of two Ordinary Fractions
        /// </summary>
        /// <returns></returns>
        public static OrdinaryFractions2 GenerateAddition()
        {
            OrdinaryFractions2 ret;

            ret.a.counter     = UniversalFunctions.Rand(1, 8);
            ret.a.denominator = UniversalFunctions.Rand(1, 9);
            ret.b.counter     = UniversalFunctions.Rand(1, 8);
            ret.b.denominator = UniversalFunctions.Rand(1, 9);
            ret._operator     = "+";

            ret.correctanswer.denominator = UniversalFunctions.LCM(ret.a.denominator, ret.b.denominator);
            int tmpCounterA = ret.a.counter * (ret.correctanswer.denominator / ret.a.denominator);
            int tmpCounterB = ret.b.counter * (ret.correctanswer.denominator / ret.b.denominator);

            ret.correctanswer.counter = tmpCounterA + tmpCounterB;
            int tmpGCD = UniversalFunctions.GCD(ret.correctanswer.counter, ret.correctanswer.denominator);

            ret.correctanswer.counter     /= tmpGCD;
            ret.correctanswer.denominator /= tmpGCD;

            return(ret);
        }
Exemple #8
0
        /// <summary>
        /// Generate Expression
        /// for example: 15% z 6 =
        /// </summary>
        /// <returns></returns>
        public static Percents2 GenerateExpression1()
        {
            Percents2 exp;

            exp.Value = UniversalFunctions.Rand(5, 100);
            int count = 0;

            do
            {
                count++;
                if (count > 150)
                {
                    count     = 0;
                    exp.Value = UniversalFunctions.Rand(5, 100);
                }
                exp.Percent = UniversalFunctions.RandDecimal(0.01m, 1.0m, 100);
            } while ((exp.Value * exp.Percent) != (int)(exp.Value * exp.Percent));

            exp.correctvalue = exp.Value * exp.Percent;
            exp.displayvalue = Convert.ToString((int)(exp.Percent * 100)) + "% z " + Convert.ToString(exp.Value) + " =";

            return(exp);
        }
 /// <summary>
 /// Return expression of Floating Points
 /// </summary>
 /// <returns></returns>
 public static ValueDecimal2 GetValue()
 {
     return(data[UniversalFunctions.Rand(1, count)]);
 }