Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Mo3adalaTarbe3ia
- {
- class Program
- {
- static void Main(string[] args)
- {
- double a;
- double b;
- double c;
- Console.WriteLine("enter a,b,c");
- a = double.Parse(Console.ReadLine());
- b = double.Parse(Console.ReadLine());
- c = double.Parse(Console.ReadLine());
- if (a == 0)
- {
- Console.WriteLine("Error, 'A' should not be zero");
- }
- else
- {
- double delta = b * b - 4 * a * c;
- if (delta == 0)
- {
- // one solution
- Console.WriteLine("Your numbers have 1 Solution ");
- //double sol = -b / 2 * a;
- Console.WriteLine("x1 = {0}", -b / 2 * a);
- }
- else
- {
- if (delta > 0)
- {
- // two solutions
- Console.WriteLine("Your numbers have 2 Solutions ");
- double deltasqrt = Math.Sqrt(delta);
- double x1 = (-b + deltasqrt) / (2 * a);
- double x2 = (-b - deltasqrt) / (2 * a);
- Console.WriteLine("x1 = {0:f2}", x1);
- Console.WriteLine("x2 = {0:f2}", x2);
- }
- else
- {
- if (delta < 0)
- {
- Console.WriteLine("Your numbers have no Solutions ");
- }
- }
- }
- // min or max point
- double x = -b / (2 * a);
- double y = a * x * x + b * x + c;
- String st;
- if (a > 0)
- {
- st = "min";
- }
- else
- {
- st = "max";
- }
- Console.WriteLine("{0} = ({1}, {2})", st, x, y);
- //Console.WriteLine("{0} = ({1}, {2})", a > 0 ? "min" : "max", x, y);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement