Create a class named Triangle, the class must contain: • Private data fields base and height with setter and getter meth
Posted: Wed Apr 27, 2022 3:12 pm
Create a class named Triangle, the class must contain: • Private data fields base and height with setter and getter methods. • A constructor that sets the values of base and height. • A method named toString() that prints the values of base and height. • A method named area() that calculates returns the area of a triangle. Create a class named Test to test the Triangle class. The Test class must contain the main() method. In the main() method: • Create an object named "t1" from class Triangle (with base = 7.2 and, height = 12.3). • Print the area of the triangle "t1" using the area() method. • Print the base and height of the triangle "t1" using the toString() method.