Could you tell me what's wrong with my code for solving a quadratic equation? Don't be cringed out by my work, because I'm still very new to the program.
class Program
{
static void Main(string[] args)
{
double a, b, c, x1, x2, x, D;
String A;
String B;
String C;
Console.Write("a=");
A = Console.ReadLine();
Console.Write("b=");
B = Console.ReadLine();
Console.Write("c=");
C = Console.ReadLine();
a = Convert.ToDouble(A);
b = Convert.ToDouble(B);
c = Convert.ToDouble(C);
D =(b * b - 4 * a * c);
if (D > 0)
{
x1 = (-b + Math.Sqrt(D)) / (2 * a);
x2 = (-b - Math.Sqrt(D)) / (2 * a);
Console.WriteLine("x1=" + x1);
Console.WriteLine("x2=" + x2);
}
else
if (D < 0)
{
D = -D;
x1 = (-b + Math.Sqrt(D)) / (2 * a);
x2 = (-b - Math.Sqrt(D)) / (2 * a);
}
else
{
x = (-b / (2 * a));
Console.WriteLine("x=" + x);
}
Console.ReadKey();
}
}
It doesn't display any values when it is run.