Define a class called Triangle that is capable of computing the perimeter and ar
ID: 3543085 • Letter: D
Question
Define a class called Triangle that is capable of computing the perimeter and area of a triangle, given its three sides a, b, and c, as shown below. Notice that side b is the base of the triangle.
The design of this class is identical to that for the Ch5Circle class from Section 5.1. Define a private method isValid to check the validity of three sides. If any one of them is invalid, the methods getArea and getPerimeter will return the constant INVALID_DIMENSION.
Define a class called Triangle that is capable of computing the perimeter and area of a triangle, given its three sides a, b, and c, as shown below. Notice that side b is the base of the triangle. The design of this class is identical to that for the Ch5Circle class from Section 5.1. Define a private method isValidto check the validity of three sides. If any one of them is invalid, the methods getArea and getPerimeter will return the constant INVALID_DIMENSION.Explanation / Answer
Complete code with sample Output
Sample Output 1
Enter the first side of the triangle
3
Enter the second side of the triangle
4
Enter the third side of the triangle
5
The perimeter of the triangle is :12.0
The area of the triangle is :6.0
Sample output 2
Enter the first side of the triangle
3
Enter the second side of the triangle
4
Enter the third side of the triangle
10
INVALID_DIMENSION
INVALID_DIMENSION
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.