# Finding The Area Of A Triangle

The reason you’re not getting a correct answer is because you are not finding the sides correctly. However, after finding the side length you can get the answer. Here is what I did:

public static void main(String[] args)
{
Scanner input = new Scanner(System.in);

System.out.println("Enter three points for a triangle:");

//Store the values in an array.
double[] xCoordinates = new double;
double[] yCoordinates = new double;
double[] sides = new double;

//      Input the values into the array
xCoordinates = input.nextDouble();
yCoordinates = input.nextDouble();
xCoordinates = input.nextDouble();
yCoordinates = input.nextDouble();
xCoordinates = input.nextDouble();
yCoordinates = input.nextDouble();

//      Find the side length from the input. There probably are better ways to do this.
sides = Math.sqrt(Math.pow(xCoordinates-xCoordinates, 2)+Math.pow(yCoordinates-yCoordinates, 2));
sides = Math.sqrt(Math.pow(xCoordinates-xCoordinates, 2)+Math.pow(yCoordinates-yCoordinates, 2));
sides = Math.sqrt(Math.pow(xCoordinates-xCoordinates, 2)+Math.pow(yCoordinates-yCoordinates, 2));

//      Find s from the sides
double s = ( sides+sides+sides )/2;

//      Find the area.
double area = Math.sqrt(s*( s-sides )*( s-sides )*( s-sides ));

//      Print the area
System.out.println("The area of the triangle is "+area);

//      Output~~~~~~~~~~~~~~~
//Enter three points for a triangle:
//      1.5
//      -3.4
//      4.6
//      5
//      9.5
//      -3.4
//      The area of the triangle is 33.600000000000016
}'