Saturday, September 29, 2012

Quadratic Equation in C#

This is for programmers. If you have problem in College Algebra and learner of computer programming then go ahead and copy and paste this code then you can do the assignments in few seconds.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace dQuadratic_Equation
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnSolve_Click(object sender, EventArgs e)
        {
            double A = Convert.ToDouble(coeffXx.Text);
            double B = Convert.ToDouble(coeffX.Text);

            double C = Convert.ToDouble(consTant.Text);
           

            double E = -B - Math.Sqrt((Math.Pow(B,2) - 4*A*C));
            double F = -B + Math.Sqrt((Math.Pow(B,2) - 4*A*C));
          
         
            double G = 2 * A;

            double Xp =(E)/(G);
            double Xn = (F)/(G);

            positiveX.Text = Xp.ToString();
            negativeX.Text = Xn.ToString();

        }

        private void btnEraser_Click(object sender, EventArgs e)
        {
          
            coeffX.Clear();
            coeffXx.Clear();
            consTant.Clear();
            coeffXx.Focus();
        }

        private void btnOff_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

This will make your life much easier.

No comments:

Post a Comment