Create a class named Triangle, the class must contain: • Private data fields base and height with setter and getter meth

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
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

Post by answerhappygod »

Create A Class Named Triangle The Class Must Contain Private Data Fields Base And Height With Setter And Getter Meth 1
Create A Class Named Triangle The Class Must Contain Private Data Fields Base And Height With Setter And Getter Meth 1 (69.12 KiB) Viewed 49 times
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!
Post Reply