Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
quadratics
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here double a, b, c, h, k; a = 1; b = -2; c = -7; h = -b/(2*a); k = -(Math.Pow(b,2)-4*a*c)/(4*a); // a is not 1 if (a!=1) { if (h>0 && k>0) { Console.WriteLine("y = {0}(x - {1})^2 + {2}",a,Math.Abs(h),Math.Abs(k)); } else if (h>0 && k<0) { Console.WriteLine("y = {0}(x - {1})^2 - {2}",a,Math.Abs(h),Math.Abs(k)); } else if (h>0 && k==0) { Console.WriteLine("y = {0}(x - {1})^2",a,Math.Abs(h)); } else if (h<0 && k>0) { Console.WriteLine("y = {0}(x + {1})^2 + {2}",a,Math.Abs(h),Math.Abs(k)); } else if (h<0 && k<0) { Console.WriteLine("y = {0}(x + {1})^2 - {2}",a,Math.Abs(h),Math.Abs(k)); } else if (h<0 && k==0) { Console.WriteLine("y = {0}(x + {1})^2",a,Math.Abs(h)); } else if (h==0 && k>0) { Console.WriteLine("y = {0}x^2 + {2}",a,Math.Abs(k)); } else if (h==0 && k<0) { Console.WriteLine("y = {0}x^2 - {2}",a,Math.Abs(k)); } else Console.WriteLine("y = {0}x^2 - {2}",a); } // a is 1 else if (a==1) { if (h>0 && k>0) { Console.WriteLine("y = (x - {0})^2 + {1}",Math.Abs(h),Math.Abs(k)); } else if (h>0 && k<0) { Console.WriteLine("y = (x - {0})^2 - {1}",Math.Abs(h),Math.Abs(k)); } else if (h>0 && k==0) { Console.WriteLine("y = (x - {0})^2",Math.Abs(h)); } else if (h<0 && k>0) { Console.WriteLine("y = (x + {0})^2 + {1}",Math.Abs(h),Math.Abs(k)); } else if (h<0 && k<0) { Console.WriteLine("y = (x + {0})^2 - {1}",Math.Abs(h),Math.Abs(k)); } else if (h<0 && k==0) { Console.WriteLine("y = (x + {0})^2",Math.Abs(h)); } else if (h==0 && k>0) { Console.WriteLine("y = x^2 + {0}",Math.Abs(k)); } else if (h==0 && k<0) { Console.WriteLine("y = x^2 - {0}",Math.Abs(k)); } else Console.WriteLine("y = x^2"); } // a is 0 else { if (k>0) { Console.WriteLine("y = {0}",Math.Abs(k)); } else if (k<0) { Console.WriteLine("y = - {0}",Math.Abs(k)); } else { Console.WriteLine("y = 0"); } } Console.WriteLine(h); Console.WriteLine(k); } } }
run
|
edit
|
history
|
help
0
test1
comparer implementation
test using C#2019
Random number generator with IF
Secure random string
RegularExpressions
Xml in C#
Sort A List : Print the sorted list of ages of the students
Adding two arrays and print it out..the crude approach
Main4