Triangle Class Design Class Named Triangle Extends Geometricobject Class Contains 1 Three Q37050836

The Triangleclass

Design a class named Triangle that extends­GeometricObject. The class contains:

1 Three double data fields namedside1, side2, andside3 with default values 1.0 todenote three sides of a triangle.

2 A no-arg constructor that creates a default triangle.

3 A constructor that creates a triangle with the specifiedside1, side2, andside3.

4 The accessor methods for all three data fields.

5 A method named getArea() that returns thearea of this triangle.

6 A method named getPerimeter() that returnsthe perimeter of this triangle.

7 A method named toString() that returns astring description for the triangle. (Overriding method)

The formula to compute the area of a triangle:

sides a,b and c

s=a+b+c2a0sLi7s8jeAAAAAElFTkSuQmCC     Area=s(s-a)(s-b)(s-c)z5Sz32xAdhAAAAAElFTkSuQmCC

The

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.