Untitled
raw download clone
TEXT
views 16
,
size 806 b
Console.WriteLine("\nPart 4, solving a quadratic equation.");
            Console.Write("a: ");
            string userInput = Console.ReadLine();
            double a = double.Parse(userInput);

            Console.Write("b: ");
            userInput = Console.ReadLine();
            double b = double.Parse(userInput);

            Console.Write("c: ");
            userInput = Console.ReadLine();
            double c = double.Parse(userInput);

            Console.WriteLine("{0} {1} {2}", a, b, c);

            double x1 = (-b + Math.Sqrt(b * b - 4 * a * c)) / (2 * a); 
            double x2 = (-b - Math.Sqrt(b * b - 4 * a * c)) / (2 * a); 

            Console.WriteLine($"The positive solution is {0}", x1);
            Console.WriteLine($"The negative solution is {1}", x2);
close fullscreen
Login or Register to edit or fork this paste. It's free.