Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Mainjava public class Main public static void mainString args create instance of each class Circle c... blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

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

Introductory Classical Mechanics

Authors: David Morin

1st edition

9780511808951, 521876222, 978-0521876223

More Books

Students also viewed these Programming questions

Question

=E* e. Expand the model to full scale, and then solve it.

Answered: 1 week ago