Hello Guys,
I'm considerably Newbie to any programming whatsoever, and i'm having to take Java for my computer Science requirement. I'm currently working on an homework assignment to write an application that reads the (X,Y) coordinates for two points. I also need to compute the distance between them using the following formula
distance = sqrt((X2-X1)^2 + (Y2-Y1)^2
So far, what i have is:
import java.util.Scanner;
//Reads the (X, Y) coordinates for two points
class Assignment2b{
public static void main (String[] args) {
Scanner scan = new Scanner (System.in);
System.out.print("Enter the value of X1 ");
System.out.flush();
int X1 = scan.nextInt;
System.out.print("Enter the value of X2 ");
System.out.flush();
int X2 = scan.nextInt;
System.out.print("Enter the value of Y1 ");
System.out.flush();
int Y1 = scan.nextInt;
System.out.print("Enter the value of Y2 ");
System.out.flush();
int Y2 = scan.nextInt;
double distance = Math.sqrt(Math.pow(X2-X1, 2) + Math.pow(Y2-Y1, 2));
System.out.println("The distance is" + distance);
}
}
I'd appreciate any helpful insights.