Beispiel #1
0
        public void Test_Discriminant_1_1_1()
        {
            double a = 1;
            double b = 1;
            double c = 1;

            var d = _discriminant.CalculationDiscriminant(a, b, c);

            Assert.AreEqual(-3, d.D);
        }
Beispiel #2
0
        public void Test_Discriminant_1_10_1()
        {
            double a = 1;
            double b = 10;
            double c = 1;

            var d = _discriminant.CalculationDiscriminant(a, b, c);

            Assert.IsTrue(d.x1 < 0, d.x1.ToString());
            Assert.IsTrue(d.x2 < 0, d.x2.ToString());
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var discriminant = new Discriminant();

            Console.WriteLine("Input value а, not equal 0");
            //for value а
            double a;
            string vvod_znach = Console.ReadLine();

            a = CheckNumber(vvod_znach);
            ProverkaDeleniya(a);

            //for value b
            Console.WriteLine("Введите b:");
            double b;

            vvod_znach = Console.ReadLine();
            b          = CheckNumber(vvod_znach);

            //for value c
            Console.WriteLine("Введите c:");
            double c;

            vvod_znach = Console.ReadLine();
            c          = CheckNumber(vvod_znach);

            var _discriminant = discriminant.CalculationDiscriminant(a, b, c);

            if (_discriminant.D < 0)
            {
                Console.WriteLine("The discriminant is D = {0} and less than 0, therefore the equation has no roots!", _discriminant.D);
            }
            else
            {
                if (_discriminant.D > 0)
                {
                    Console.WriteLine("The discriminant is D = {2} and greater than 0, therefore the equation has two roots: {0} and {1}", _discriminant.x1, _discriminant.x2, _discriminant.D);
                }
                else
                {
                    Console.WriteLine("The discriminant is D = {1}, therefore the equation has one root: {0}", _discriminant.x1, _discriminant.D);
                }
            }

            //Console.WriteLine("Разложение на линейные множители:");
            //Console.WriteLine("{0}*x*x+{1}*x+{2}={0}*(x-{3})*(x-{4})", a, b, c, x1, x2);
            Console.ReadKey();
        }
Beispiel #4
0
        public void TestDiscriminant(int a, int b, int c, int expect)
        {
            var d = discriminant.CalculationDiscriminant(a, b, c);

            Assert.AreEqual(expect, d.D);
        }