Question: Define a class Shape with an abstract method CalculateArea(). Define two additional classes for a triangle and a rectangle with fields width and height (values

Define a class Shape with an abstract method CalculateArea(). Define two additional classes for a triangle and a rectangle with fields width and height (values being set through appropriate constructors), which implement CalculateArea(). This method has to return the areas of the rectangle (height*width) and the triangle (height*width/2). Define another class for a circle with an appropriate constructor, which initializes the two fields (height and width) with the same value (the radius) and implements the abstract method for calculating the area. 

Create an array of different shapes and calculate the area of each shape in another array.

Step by Step Solution

3.43 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Mainjava public class Main public static void mainString args create instance of each class Circle c... View full answer

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!