Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. static void Main(string[] args)
  2.         {
  3.  
  4.             int x1;
  5.             int x2;
  6.             int y1;
  7.             int y2;
  8.             double m;
  9.             double yint;
  10.  
  11.             Console.Write("Enter x1 value: ");
  12.             x1 = Convert.ToInt16(Console.ReadLine());
  13.             Console.Write("Enter x2 value: ");
  14.             x2 = Convert.ToInt16(Console.ReadLine());
  15.             Console.Write("Enter y1 value: ");
  16.             y1 = Convert.ToInt16(Console.ReadLine());
  17.             Console.Write("Enter y2 value: ");
  18.             y2 = Convert.ToInt16(Console.ReadLine());
  19.  
  20.             Console.WriteLine();
  21.  
  22.             m = slope(x1,x2,y1,y2);
  23.             yint = yInt(x1, y1, m);
  24.  
  25.             Console.WriteLine("Slope: " + m);
  26.             Console.WriteLine("Y-Intercept: " + yint);
  27.         }
  28.  
  29.         //x1,x2,y1,y2
  30.         static double slope(int a, int b, int c, int d)
  31.         {
  32.             double m = (d-c) / (b-a);
  33.             return m;
  34.         }
  35.  
  36.         //x,y,slope
  37.         static double yInt(int a, int b, double c)
  38.         {
  39.             double testNum = a*c;
  40.             double yIntercept = b - (testNum);
  41.             return yIntercept;
  42.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement