title: My c# program for square roots only works when the discriminant is 0 or less than 0, but not when it's greater than 0
body: <pre><code>private void btnCompute_Click(object sender, EventArgs e)
  {
      double coefficientA;
      double coefficientB;
      double coefficientC;
      double root1;
      double root2;
      double discriminant;
  
      coefficientA = double.Parse(txtCoeA.Text);
      coefficientB = double.Parse(txtCoeB.Text);
      coefficientC = double.Parse(txtCoeC.Text);
  
      discriminant = 
              (coefficientB * coefficientB) - 
              (4 * coefficientA * coefficientC);
  
      txtOutput.Text = "Discriminant = " + discriminant.ToString("N2");
  
      //-b/2a
  
      root1 = (-coefficientB + discriminant) / (2 * coefficientA);
      root2 = (-coefficientB - discriminant) / (2 * coefficientA);
  
      if (discriminant &lt; 0)
      {
              txtOutput.Text += "\r\nEquation has no real roots!";
      }
      else if (discriminant == 0)
      {
          txtOutput.Text += 
              "\r\nEquation has one root: " + root2.ToString("N2");
      }        
      else if (discriminant &gt; 0)
      {
          txtOutput.Text = "Equation has two real roots: " +
              "\r\nroot1: " + 
              (-coefficientB + Math.Sqrt(discriminant) / 
              (2 * coefficientA)) +
              "\r\nroot2: " + (coefficientB - Math.Sqrt(discriminant) / 
              (2 * coefficientA)); 
      }
  }
  </code></pre>