Kristo R

Kristo R

  • NA
  • 1
  • 1.9k

Beginner question about quadratic equation calculator

Sep 12 2012 1:27 PM
I made a quadratic equation calculator but it doesn't work. Any ideas?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace quadratic
{
    class quadratic
    {
        static void Main(string[] args)
        {
            int a, b, c;
            double x1, x2;

           
                Console.Write("Please enter the value of A: ");
                a = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine();

                Console.Write("Please enter the value of B: ");
                b = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine();

                Console.Write("Please enter the value of C: ");
                c = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine();
           
           
            x1 = (-a + Math.Sqrt(b * b - 4 * a * c))/(2 * a);
            x2 = (-a - Math.Sqrt(b * b - 4 * a * c))/(2 * a);

            Console.WriteLine(x1);
            Console.WriteLine(x2);
        }
    }
}

Answers (1)