Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. To compute the triangle area, ensure that all side lengths are positive and the sum of any two side lengths is greater than the

image text in transcribedimage text in transcribed
4. To compute the triangle area, ensure that all side lengths are positive and the sum of any two side lengths is greater than the third side length. 5. The program should automatically create 3 Triangle and 3 Square objects and print out all their properties. For example, the program would return the following output upon execution: Square Sides: [2] Area: 4 Triangle Sides: [7, 2, 9] Area: 0.0 Square Sides: [6] Area: 36 Triangle Sides: [9, 8, 6] Area: 23.53 Square Sides: [7] Area: 49 Triangle Define four classes, Polygon , Rectangle , Square ,and Triangle . Polygon is the parent class of Rectangle , which is the parent class of Square . Polygon also is the parent class of the Triangle class. This figure might be helpful to visualize the hierarchy of these classes. 1. The Polygon should have the following methods: - A method called WhoAmI that prints out Triangle if the current object is a triangle or Square if the current object is a square. - A method called side_lengths to print the side lengths of the polygon. o A method called findArea() that can be overridden to compute and return the Polygon area. 2. When creating Rectangle objects, the program should generate two random integers as the sides of the rectangle. Similarly, the program should randomly generate one random integer denoting one side for' Square' objects. The side lengths can be any value between 1 and 10, inclusively. 3. Each of the Rectangle , Triangle and Square classes should have a method called findArea() that computes and returns the respective area according to the following formulae: SquareArea = side2 RectangleArea = side] X side; TriangleArea = 1/p(p side1)(p side2)(p side3), where p = W

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Quantitative Methods For Business

Authors: David Anderson, Dennis Sweeney, Thomas Williams, Jeffrey Cam

11th Edition

978-0324651812, 324651813, 978-0324651751

Students also viewed these Mathematics questions