Esempio n. 1
0
        private void ToBinomialButton_Click(object sender, EventArgs e)
        {
            BinomialQuadratic bgn = new BinomialQuadratic(1, 1, 1);

            Display.Text = "Quadratic-Binomial Solver    (C)Michael Wang";
            try
            {
                bgn = new BinomialQuadratic(InputBox.Text);
                Faker.NewLine(Faker.question + ". Convert the quadratic, " + bgn.AsString() + " to a binomial");
                progressBar.Value = 0;
            }
            catch
            {
                Display.Text += "\r\n\r\nOutput:" +
                                "\r\nThis is not a quadratic(binomial format); Invalid format; \r\n" +
                                "should be of ax^2+bx+c";
                return;
            }
            Binomial otp = wizard.ToBinomial(bgn);

            Faker.NewLine("=" + otp.AsString());
            Display.Text += "\r\nBegining Value:\r\n" + bgn.AsString();
            Display.Text += "\r\nOutput:\r\n" + otp.AsString();
            Faker.NewLine("This is because " + bgn.a + "/" + bgn.c + "=" + otp.a + "+" + otp.b);
            Faker.NewLine("and " + bgn.b + "/" + bgn.c + "=" + otp.a + "*" + otp.b);
            Faker.NewLine("");
            Faker.question++; progressBar.Value = progressBar.Maximum;
        }
Esempio n. 2
0
        private void ToBinomialQudraticButton_Click(object sender, EventArgs e)
        {
            progressBar.Value = 0;
            Display.Text      = "Binomial-Quadratic Solver    (C)Michael Wang";
            Binomial bgn = new Binomial(1, 1, 1);

            try
            {
                bgn = new Binomial(InputBox.Text);
                Faker.NewLine(Faker.question + ". Convert the Binomial " + bgn.AsString() + " to a quadratic");
            }
            catch
            {
                Display.Text += "\r\nOutput:\r\n" +
                                "This is not a binomial; Invalid Format;\r\n" +
                                "Should be of a(x+b)(X+c)";
                return;
            }
            Display.Text +=
                "\r\nBegining Value\r\n" + bgn.AsString();
            BinomialQuadratic otp = new BinomialQuadratic((bgn.a + bgn.b) * bgn.c, bgn.a * bgn.b * bgn.c, bgn.c);

            Faker.NewLine(bgn.c + "X^2+(" + bgn.a + "+" + bgn.b + ")*" + bgn.c + "X+" + bgn.a + "*" + bgn.b + "*" + bgn.c);
            Faker.NewLine("=" + otp.AsString());
            Faker.NewLine("");
            Display.Text += "\r\n\r\n" +
                            "Output Value\r\n" + otp.AsString();
            progressBar.Value = progressBar.Maximum;
        }
Esempio n. 3
0
        public Binomial ToBinomial(BinomialQuadratic quadratic)
        {
            double bgna = quadratic.c;
            double bgnb = quadratic.a;
            double bgnc = quadratic.b;

            double item = Math.Sqrt((bgnb * bgnb) - (4 * bgna * bgnc));
            double b    = (-bgnb + item) / (2 * bgna);
            double c    = (-bgnb - item) / (2 * bgna);


            return(new Binomial(-b, -c, bgna));
        }
Esempio n. 4
0
        private void RandomQuadraticButton_Click(object sender, EventArgs e)
        {
            progressBar.Value = 0;
            Random random = new Random();
            bool   bi     = false;
            object otp;

            Display.Text = "Generating Random Quadratic...";
            if (random.Next(0, 2) == 1)
            {
                bi = true;
            }
            if (bi)
            {
                int a = random.Next(1, 50);
                int b = random.Next(1, 50);
                int c = random.Next(1, 50);
                otp = new BinomialQuadratic((a + b) * c, a * b * c, c);
            }
            else
            {
                int a = random.Next(1, 50);
                int b = random.Next(1, 50);
                int c = random.Next(1, 50);
                int d = random.Next(1, 50);
                otp = new TrinomialQuadratic(d * c + a + b, a * b + c * a + b * a, c * a * b, d);
            }
            Display.Text = "Random Quadratic Generator  (C)Michael Wang\r\nOutput:\t\n";
            if (bi)
            {
                BinomialQuadratic temp = (BinomialQuadratic)otp;
                Display.Text += temp.AsString();
            }
            else
            {
                TrinomialQuadratic temp = (TrinomialQuadratic)otp;
                Display.Text += temp.AsString();
            }
        }