Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Interface: objects In objects class are 2 methods, area and perimeter Super Clas

ID: 3675148 • Letter: I

Question

Interface:
   objects

   In objects class are 2 methods, area and perimeter

Super Classes:
   circle
   rectangle
   triangle

   Create a constructor and at least 1 general method for each class.
  

Sub Classes:
   subcircle
   subrectangle
   subtriangle

   Create a constructor for the subclass and at least 2 methods for each subclass.
  
      
Problem: Create a program that demonstrates the use of an interface and inheritance.
   Create objects, call on methods, and compute different formulas for each case.

Explanation / Answer

Answer--

#include <iostream.h>

#include <conio.h>

#include <math.h>

class shape

{

protected:

       double x,y,z;

public:

      void get_data()=0;

      void display_area()=0;

void display_paremeter ()=0;

};

Class circle : public shape

{

Public:

Void get_data()

{

Cout<<”” enter data for circle ”;

Cout<<”enter radius for circle “;

Cin>>x;

}

Void display_area()

{

Cout<<” Area of circle”;

Double a;

a=pi*math.pow*x*x;

Cout<<”Area of circle is”<<a;

}

Void display_parameter()

{

Cout<<’ parameter of circle ”;

double b;

b=2*pi*x;

cout<<”parameter of circleis”<<b;

}

};

class triangle : public shape

{

   public:

    void get_data()

    {

       cout<<" Enter Datafor Triangl ";

       cout<<"Enter base, height,width : ";

       cin>>x>>y>>z;

    }

Void display_parameter()

{

Cout<< Parameter of triangle ”;

double b1;

b1=x+y+z;

cout<< parameter of triangle <<b1;

}

    void display_area()

    {

       cout<<" Area of Triangle ";

       double a1

     cout<<"Area of Triangle is "<<a1;

    }

};

class rectangle : public shape

{

   public:

    void get_data()

    {

       cout<<" Data Entry for Rectangle ";

       cout<<"Enter length of two sides : ";

       cin>>x>>y;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote