Skip to content

Instantly share code, notes, and snippets.

@thmain
Created June 2, 2018 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/9e87d629debec8c4f4d21d5982c46416 to your computer and use it in GitHub Desktop.
Save thmain/9e87d629debec8c4f4d21d5982c46416 to your computer and use it in GitHub Desktop.
public class AreaOfTriangleCoordinates {
public static void printArea(double [] X, double [] Y){
//find area of triangle
double area = Math.abs(X[0]*(Y[1]-Y[2]) + X[1]*(Y[2]-Y[0]) + X[2]*(Y[0]-Y[1]))/2;
System.out.println("Area of Triangle: " + area);
}
public static void main(String[] args) {
double [] x_coordinates = {1,2,5};
double [] y_coordinates = {0, 6, 10};
printArea(x_coordinates, y_coordinates);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment