Question: Create a class named Triangle. The class must contain: Private data fields for base and height with setter and getter methods. A constructor that initializes
Create a class named Triangle. The class must contain:
Private data fields for base and height with setter and getter methods.
A constructor that initializes the values of base and height.
A method named area that calculates and returns the area of the triangle
using the formula:
Area base height
Create a class named TestTriangle to test the Triangle class. The TestTriangle
class must contain the main method. In the main method, do the following:
Create an object of the Triangle class with base and height
Print the base, height, and area of the triangle object
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
