Beispiel #1
0
        public void TestCase()
        {
            double wait = -0.5;
            double real = QuadricEquation.Solver(2, 3, 1, 1);

            Assert.AreEqual(wait, real, 0.1);
        }
Beispiel #2
0
        private static void MenuForQuadEquation()
        {
            double a, b, c, d, x1, x2;

            Output.Print("Hello, I can solve equation: ax^2+bx+c=0.\n");
            Output.Print("Input a:");
            a = CorrectInteger();
            Output.Print("Input b:");
            b = CorrectInteger();
            Output.Print("Input d:");
            c = CorrectInteger();


            if (a != 0)
            {
                d = b * b - 4 * a * c;

                if (d > 0)
                {
                    x1 = QuadricEquation.Solver(a, b, d, 1);
                    x2 = QuadricEquation.Solver(a, b, d, -1);

                    Output.Print("\nThere are two decisions:");
                    Output.Print("\nx1 = " + x1);
                    Output.Print("\nx2 = " + x2);
                }
                else if (d == 0)
                {
                    x1 = QuadricEquation.Solver(a, b, d, 1);

                    Output.Print("\nThere are two decisions but they are the same:");
                    Output.Print("\nx1 = x2 = " + x1);
                }
                else
                {
                    Output.Print("\nNo decision!");
                }
            }
            else
            {
                Output.Print("\nA can't equals 0!!!");
            }
        }