Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is from project 4.1 from \"Big Java.\" In this project, you perform calcula

ID: 3621245 • Letter: T

Question

This is from project 4.1 from "Big Java."

In this project, you perform calculations with triangles. A triangle is defined by the x- and y-coordinates of its three corner points. Your job is to compute the following properties of a given triangle:

-the lengths of all sides
-the perimeter
-the angles at all corners
-the area

Of course you should implement a Triangle class with appropriate methods. Supply a program that prompts a user for the corner point coordinates and produces a nicely formatted table of the triangle properties.

Please help I am having major trouble doing this question

Explanation / Answer

please rate - thanks

import java.util.*;
public class triangle
{public static void main(String [] args)
     {double x1,x2,x3,y1,y2,y3,s1,s2,s3,p,a1,a2,a3,a,f=180./3.14;
    Scanner in = new Scanner(System.in);
     System.out.println("enter point 1 of triangle");
     System.out.print("enter x: ");
    x1=in.nextDouble();
    System.out.print("enter y: ");
    y1=in.nextDouble();
     System.out.println("enter point 2 of triangle");
     System.out.print("enter x: ");
    x2=in.nextDouble();
    System.out.print("enter y: ");
    y2=in.nextDouble();
     System.out.print("enter point 3 of triangle");
     System.out.print("enter x: ");
    x3=in.nextDouble();
    System.out.print("enter y: ");
    y3=in.nextDouble();
    s1=getside(x1,y1,x2,y2);
    s2=getside(x1,y1,x3,y3);
    s3=getside(x3,y3,x2,y2);
    a=area(s1,s2,s3);
    p=perimeter(s1,s2,s3);
    a1=Math.acos(((s1*s1+s2*s2-s3*s3)/(2*s1*s2)))*f;//1 angle
     a2=Math.acos(((s3*s3+s2*s2-s1*s1)/(2*s3*s2)))*f; // angle 2
     a3=Math.acos(((s1*s1+s3*s3-s2*s2)/(2*s1*s3)))*f; //angle 3
    System.out.println("Your Triangle");
    System.out.println("points:   ("+x1+","+y1+"),("+x2+","+y2+"),("+x3+","+y3+")");
    System.out.println("sides:     "+s1+"          "+s2+"          "+s3);
    System.out.println("angles:    "+a1+"          "+a2+"          "+a3);
    System.out.println("area:      "+a);
    System.out.println("perimeter: "+p);
    }
public static double area(double side1, double side2, double side3)
{double s;
s=(side1+side2+side3)/2;
return Math.sqrt(s*(s-side1)*(s-side2)*(s-side3));
}
public static double perimeter(double side1, double side2, double side3)
{return side1+side2+side3;
}
public static double getside(double x1, double y1, double x2, double y2)
{return Math.sqrt(Math.pow(Math.abs(x1-x2),2)+Math.pow(Math.abs(y1-y2),2));
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote