public void FindKAndB(double x1, double y1, double x2, double y2, double expectedK, double expectedB) { double actualK = VariablesMath.SolveIndexK(x1, y1, x2, y2); double actualB = VariablesMath.SolveIndexB(x1, y1, x2, y2); Assert.AreEqual(expectedK, actualK); Assert.AreEqual(expectedB, actualB); }
public void FindKAndBNegative(double x1, double y1, double x2, double y2) { try { VariablesMath.SolveIndexK(x1, y1, x2, y2); VariablesMath.SolveIndexB(x1, y1, x2, y2); } catch { Assert.Pass(); } Assert.Fail(); }
static void Main(string[] args) { double x1, y1, x2, y2; Console.WriteLine("Enter x1:"); x1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter y1:"); y1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter x2:"); x2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter y2:"); y2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("A (" + x1 + "," + y1 + ")"); Console.WriteLine("B (" + x2 + "," + y2 + ")"); double k = VariablesMath.SolveIndexK(x1, y1, x2, y2); double b = VariablesMath.SolveIndexB(x1, y1, x2, y2); Console.Write("Stright line equation: y="); Console.Write(k + "*x + " + b); }