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

Following the example of the Circle class, design a class named Triangle to repr

ID: 3666783 • Letter: F

Question

Following the example of the Circle class, design a class named Triangle to represent a triangle. The class contains:

- Three double data fields named a, b, and c that specify the sides of the triangle.

- A no-arguments constructor that creates a default triangle. The default values are 1 for all three.

- A constructor that creates a triangle with the specified sides, pro- vided that they are all positive and preserve the triangle inequal- ity 1. Otherwise, stops the program.

- A method named getArea() that returns the area of this triangle.

- A method named getPerimeter() that returns the perimeter of this triangle.

Write a test program that creates a triangle object with sides 3,4 and 5. Display the sides, area, and perimeter of the triangle.

Explanation / Answer

Please find below the required Triangle class and a test class :