Exemple #1
0
        public static string EquazioneSecondoGrado(double a, double b, double c)
        {
            double delta = Equazioni.Delta(a, b, c);
            double x1 = 0, x2 = 0;

            if (delta == 0)
            {
                x1 = -b / (2 * a);
                return($"L'equazione ha una sola soluzione: {x1}");
            }
            else if (delta < 0)
            {
                return("L'equazione è impossibile");
            }
            else
            {
                Equazioni.CalcoloSoluzioni(a, b, ref x1, ref x2, delta);
                Equazioni.CambioVariabili(ref x1, ref x2);
                return($"L'equazione ha una due soluzioni {x1} e {x2}");
            }
        }
Exemple #2
0
        public static string EquationDegree2(double a, double b, double c)
        {
            string e;
            string f;
            double delta = Equazioni.Delta(a, b, c);

            if (b == 0 && c != 0)
            {
                e = ((Math.Sqrt(-c)) / a).ToString();
                f = (-(Math.Sqrt(-c)) / a).ToString();
                return($"e è {e} e f è {f}");
            }
            else if (b != 0 && c == 0)
            {
                e = 0.ToString();
                f = (-b / a).ToString();
                return($"e è {e} e f è {f}");
            }
            else if (a != 0 && b != 0 && c != 0)
            {
                if (delta > 0)
                {
                    e = (-b - Math.Sqrt(delta) / (2 * a)).ToString();
                    f = (-b + Math.Sqrt(delta) / (2 * a)).ToString();
                    return($"e è {e} e f è {f}");
                }
                else if (delta == 0)
                {
                    f = e = (-b / (2 * a)).ToString();
                    return($"e è {e} e f è {f}");
                }
                else if (delta < 0)
                {
                    return("Impossible");
                }
            }
            return("");
        }
        public static string EquationDegree2(double a, double b, double c)
        {
            string x1;
            string x2;
            double delta = Equazioni.Delta(a, b, c);

            if (b == 0 && c != 0)
            {
                x1 = ((Math.Sqrt(-c)) / a).ToString();
                x2 = (-(Math.Sqrt(-c)) / a).ToString();
                return($"x1 è {x1} e x2 è {x2}");
            }
            else if (b != 0 && c == 0)
            {
                x1 = 0.ToString();
                x2 = (-b / a).ToString();
                return($"x1 è {x1} e x2 è {x2}");
            }
            else if (a != 0 && b != 0 && c != 0)
            {
                if (delta > 0)
                {
                    x1 = (-b - Math.Sqrt(delta) / (2 * a)).ToString();
                    x2 = (-b + Math.Sqrt(delta) / (2 * a)).ToString();
                    return($"x1 è {x1} e x2 è {x2}");
                }
                else if (delta == 0)
                {
                    x2 = x1 = (-b / (2 * a)).ToString();
                    return($"x1 è {x1} e x2 è {x2}");
                }
                else if (delta < 0)
                {
                    return("Impossibile");
                }
            }
            return("");
        }