Hi, need some help with this one. All I was asked was to find out if the three points are on the same line. I think that works. But I decided to go a little farther and try getting the equations of the relevant lines. That is where I am going wrong. All that is written in the Eclipse ( my IDE) console is the slopes or what I think is the slopes! Can anyone help please? By the way, this is revision. But I am very rusty and have never been a "Ace" programmer. Something I am trying to fix. Thanks in advance for any help given.
import java.util.*; public class SameStraightLine { public static void main(String[] args) { Scanner input= new Scanner(System.in); int x1,y1,x2,y2,x3,y3,m1,m2,m3,l1,l2,l3; int x= 120;char X = (char)x; int y=121; char Y= (char)y; Boolean SameLine= true; System.out.println("Please enter the x1 co-ordinate: "); x1=input.nextInt(); System.out.println("Please enter the y1 co-ordinate: "); y1=input.nextInt(); System.out.println("Please enter the x2 co-ordinate: "); x2=input.nextInt(); System.out.println("Please enter the y2 co-ordinate: "); y2=input.nextInt(); System.out.println("Please enter the x3 co-ordinate: "); x3=input.nextInt(); System.out.println("Please enter the y3 co-ordinate: "); y3=input.nextInt(); m1=((y2-y1)/(x2-x1)); m2=((y3-y2)/(x3-x2)); m3=((y1-y3)/(x1-x3)); l1=(y-y1-(m1*(x-x1))); l2=(y-y2-(m2*(x-x2))); l3=(y-y3-(m3*(x-x3))); System.out.println("The equation of the line l1 is: "+l1); System.out.println("The equation of the line l2 is: "+l2); System.out.println("The equation of the line l3 is: "+l3); if (l1==l2 && l2==l3) { System.out.println("It is "+SameLine+" that they lie on the same line"); } else { System.out.println("It is "+(!SameLine)+" that they lie on the same line"); } } }