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 =0.5* 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 =7.5 and height =12.3.
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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!