Create an interface class Figure with two member variables dim1, dim2. Create a parametrized constructor. There should be a member function called area( ), perimeter() with return type double that...


Create an interface class
Figure
with two member variables
dim1, dim2.



  • Create a parametrized constructor.

  • There should be a member function called
    area( ), perimeter()
    with return type
    double
    that computes area and perimeter of an object.


Derive two subclasses
Rectangle
and
Triangle
from
Figure.



  • Rectangle and Triangle doesn’t have any member function of their own, but inside their constructors they should be passing values to their super class
    Figure


  • Each of these subclasses (Rectangle and Triangle) should override area( )so that it should return area of rectangle and triangle.

  • The area for Rectangle is dim1*dim2

  • The area for Triangle is (dim1*dim2)/2

  • Also calculate perimeters for Rectangle. (hint 2(dim1 + dim2)

  • Also calculate perimeters for Rectangle. (hint 4(dim1).


Now create another class with main function create objects and display values.



Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here