Create a class named Triangle, the class must contain: • Private data fields base and height with setter and getter meth
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Create a class named Triangle, the class must contain: • Private data fields base and height with setter and getter meth
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.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!