title: Keep getting a an error.. dont know how to finish this
body: <pre><code>import java.util.Scanner;
  
  
  public class homework {
  
      public static  void main(String[] args) {
          double Xp;
          double Yp;
          double Xq;
          double Yq;
  
          Scanner Point1= new Scanner(System.in);
          System.out.print("Enter the First value for Xp: ");
          Xp = Point1.nextDouble();
          Scanner Point2= new Scanner(System.in);
          System.out.print("Eneter the First valuse for Yp: ");
          Yp = Point2.nextDouble();
          Scanner Point3= new Scanner(System.in);
          System.out.println("Enter the First valuse for Xq: ");
          Xq = Point3.nextDouble();
          Scanner Point4= new Scanner(System.in);
          System.out.println("Enter the First valuse for Yq: ");
          Yq = Point4.nextDouble();
          System.out.println("Point P's Coordinates are: " + "( " + Xp + "," + Yp   + ")" );
          System.out.println("Point Q's Coordinates are: " + "( " + Xq + "," + Yq   + ")" );
  
  
          if ( Xp &gt;= 1 &amp;&amp;  Yp &gt;= 0) 
          {
           System.out.println("The point P is in Quadrant 1 ");
          }
         else if ( Xp &lt;= 0 &amp;&amp; Yp&gt;=0 )
         {
          System.out.println("The point P is in Quadrant 2" );
         }
         else if ( Xp&lt;=0 &amp;&amp; Yp&lt;0)
         {
          System.out.println("The point P is in Quadrant 3" );    
         }
         else if (Xp&gt;= 0 &amp;&amp; Yp&lt;0)
         {
          System.out.println("The point P is in Quadrant 4" );    
         }  
         if ( Xq &gt;= 1 &amp;&amp;  Yq &gt;= 0) 
         {
           System.out.println("The point Q is in Quadrant 1 ");
         }
        else if ( Xq &lt;= 0 &amp;&amp; Yq&gt;=0 )
        {
          System.out.println("The point Q is in Quadrant 2" );
        }
        else if ( Xq&lt;=0 &amp;&amp; Yq&lt;0)
        {
          System.out.println("The point Q is in Quadrant 3" );    
        }
        else if (Xq&gt;= 0 &amp;&amp; Yq&lt;0)
        {
          System.out.println("The point Q is in Quadrant 4" );
          }      
      double ED=Math.sqrt((Xq-Xp)*(Xq-Xp) + (Yq-Yp)*(Yq-Yp));
      System.out.println("The Euclidean distance from p to q is :"+ ED);
  
      double slope= (Yp-Yq)/(Xp-Xq);
      if (Xp-Xq!=0)
      {
      double slope;
      System.out.println("The Slope of the Line is: "+ slope);
      }
      else if  (Xp-Xq==0){
      System.out.println("Slope Is Undefined");
      System.exit(1);
  }} }
  </code></pre>
  
  <p>The error is that I duplicated variable  <code>slope</code> and i can't figure out how to make it work without getting an error. </p>
  
  <p>What my assigment is asking for:</p>
  
  <blockquote>
    <p>(Create another method that returns the slope of the line pq formed by
    connecting p and q. The slope is expressed as m = (yp − yq)/(xp − xq),
    but it must be robust to errors caused by certain inputs.If the slope
    is undefined, do not perform the calculation due to a divide-by zero
    error. Instead, print the error message “Slope is undefined.” inside
    the method and call System.exit(1) to end your program)</p>
  </blockquote>