Прошу помочь найти ошибки в моей работе. При вводе значений получаются нули.
using System;
namespace ConsoleApp4
{
internal class Program
{
static void Main(string[] args)
{
/Console.Write("Input x: ");
int x = Convert.ToInt32(Console.ReadLine());/
Console.Write("Input a: ");
double a = Convert.ToDouble(Console.ReadLine());
Console.Write("Input b: ");
double b = Convert.ToDouble(Console.ReadLine());
Console.Write("Input c: ");
double c = Convert.ToDouble(Console.ReadLine());
if (a != 1)
{
double discriminant = Math.Abs(Math.Pow(b, 2)) - 4 * a * c;
if (discriminant > 0)
{
double root_one = (b - (b * 2) - Math.Sqrt(discriminant))/2*a;
Console.WriteLine($"First root: {0}", root_one);
double root_two = (b - (b * 2) + Math.Sqrt(discriminant))/2*a;
Console.WriteLine($"Second root: {0}", root_two);
} else if (discriminant == 0)
{
double only_root = (b - (b * 2) - Math.Sqrt(discriminant)) /2*a;
Console.WriteLine($"Only root: {0}", only_root);
} else if (discriminant < 0)
{
Console.WriteLine("There`s no roots in this equation");
}
}
else if (a == 1)
{
double discriminant = Math.Abs(Math.Pow(b, 2)) - 4 * a * c;
Console.WriteLine("Это приведенное квадратное уравнение");
double root_one = (b - (b * 2) - Math.Sqrt(discriminant)) / 2 * a;
Console.WriteLine($"First root: {0}", root_one);
double root_two = (b - (b * 2) + Math.Sqrt(discriminant)) / 2 * a;
Console.WriteLine($"Second root: {0}", root_two);
}
}
}
}
