BSO90

Quadratic Equation

Apr 27th, 2021
854
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Test
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Please enter a number for a: ");
  10.             double a = double.Parse(Console.ReadLine());
  11.             Console.WriteLine("Please enter a number for b: ");
  12.             double b = double.Parse(Console.ReadLine());
  13.             Console.WriteLine("Please enter a number for c: ");
  14.             double c = double.Parse(Console.ReadLine());
  15.             double d = (b * b) - (4 * a * c);
  16.  
  17.             Console.WriteLine("x1: {0}", -(b + Math.Sqrt(d)) / (2 * a));
  18.             Console.WriteLine("x2: {0}", -(b - Math.Sqrt(d)) / (2 * a));
  19.  
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment