title: Calculating the area of a triangle
body: <p>I am new to Java. I am trying to calculate the area of a triangle using the formula: </p>
  
  <p>s = (side 1 + side 2 + side 3)/2</p>
  
  <p>area = square root (side (side - side 1)(side - side2)(side - side3). </p>
  
  <p>If the user enter the three point as:
  1.5 -3.4 4.6 5 9.5 -3.4 then the area of the triangle should be 33.6. However, my program runs, but it's giving me an incorrect answer. Below is my code.</p>
  
  <pre><code>// Import Java Scanner
  import java.util.Scanner;
  import java.lang.Math;
  public class Ex_2_19 {
      public static void main(String[] args) {
      //Create a Scanner object
      Scanner input = new Scanner(System.in);
      float side = 0;
      float area1 = 0;
      float area2 = 0;
      float area3 = 0;
      float area4 = 0;
      float calculatedarea = 0;
  
      //Prompt the user to enter three points of a triangle
      System.out.println("Enter point x1:");
      System.out.println("Enter point y1:");
      System.out.println("Enter point x2:");
      System.out.println("Enter point y2:");
      System.out.println("Enter point x3:");
      System.out.println("Enter point y3:");
  
      //Define the variables
      float Pointx1 = input.nextFloat();
      float Pointy1 = input.nextFloat();
      float Pointx2 = input.nextFloat();
      float Pointy2 = input.nextFloat();
      float Pointx3 = input.nextFloat();
      float Pointy3 = input.nextFloat();
  
      //Formula to calculate the area of a triangle
      side = (Pointx1 + Pointy1 + Pointx2 + Pointy2 + Pointx3 + Pointy3) / 2;
      area1 = side - (Pointx1 + Pointy1);
      area2 = side - (Pointx2 + Pointy2);
      area3 = side - (Pointx3 + Pointy3);
      area4 = side * area1 * (area2) * (area3);
      calculatedarea = (float) (Math.sqrt(area4)); 
      //calculatedarea = (float) (Math.sqrt(area1)*(area2) * (area3)); 
  
      //Print result
      System.out.println("The area of the triangle is " + calculatedarea);
  
  
  }
  </code></pre>
  
  <p>}</p>