title: cartesian slope calculation error Java
body: <p>I'm having some trouble with the my cartesian slope calculations in Java.
  So my sourcecode lets you input 4 numbers, x1 y1 x2 y2, which represent 2 coordinates of 2 points in an cartesian coordinate system.</p>
  
  <p>then i calculate the slope by calculating deltaX and deltaY.
  so i use a double for the slope end calculation <code>(deltaY / deltaX)</code> in case you get a tenth of a number.</p>
  
  <p>then i use an IF function to say: <code>if slope = 0 --&gt; println("not a linear line")</code>. else calculate the cross point of the X and Y polars and println the result</p>
  
  <p>So here is the problem: what if the slope is 0 (example x1:0 y1:1 x2:0 y2:9) then the i get an error: <code>Exception in thread main java.lang.ArithmeticException: / by zero</code></p>
  
  <p><BR>
  here is the full script:</p>
  
  <pre><code>import java.io.*;
  
  public class Cartesian
  {
      public static int leesIn(String var, BufferedReader in) throws IOException
      {
          System.out.println("type een getal in die " + var + " moet voorstellen.");
          return Integer.parseInt(in.readLine());
      }
      public static void main(String[] args) throws IOException
      {
  
  
      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  
      int x1, x2, y1, y2;
      x1 = leesIn("X1", in);
      y1 = leesIn("Y1", in);
      x2 = leesIn("X2", in);
      y2 = leesIn("Y2", in);
  
      System.out.println("The Coördinates of point 1 is: (" + x1 + ", " + y1 + "). The Coördinates of point 2 is: (" + x2 + ", " + y2 + ").");
  
  
      int deltaY = y2 - y1;
      int deltaX = x2 - x1;
      double RC = deltaY / deltaX;
  
      if ((RC) == 0)
      {
          System.out.println("The slope is 0, no linear line.");
      }else
      {
          System.out.println("The slope is: " + RC);
          double B = y1-(RC*x1);
          System.out.println("The crosspoint with Y, if x is 0, : " + B);
      }
  }
  }
  </code></pre>
  
  <p>anyone an idea how to fix my problem? tnx in advance!</p>