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

Help Needed with C++ Base and Derived Classes: I need help finding the area of a

ID: 3690070 • Letter: H

Question

Help Needed with C++ Base and Derived Classes:

I need help finding the area of a rectangle, circle, and triangle. We need to create a Base class Shape and have three derived classes from the base class called Rectangle, Circle, Triangle. The user needs to be asked if they want to construct a rectangle, circle or triangle. If they say Rectangle, they need to enter a length and a width. If they say circle, they need to input a radius. If they say triangle, they need to input a base and height.

Once the area is calculated after the user picks a shape and puts in the dimensions, the constructed shape should be stored in a LinkedList. The area of the object should be printed out after each construction. I don't understand derived classes and linkedlist so I am having trouble doing this. Your help would be much appreciated!

Here is a sample output:

Explanation / Answer


#include <iostream>
using namespace std;


int rectangle (int a, int b,int c)
{
cout<<"Rectangle Construction";
cout<<"Length =";
cin>>a;
cout<<"Breath =";
cin>>b;
c=a*b;
cout<<"Area ="c;
}

int circle(int r,float x)
{
   cout<<"Circle construction";
   cout<<"Radius =";
    cin>>r;
   x=((22/7)*r*r);
   cout<<"Area ="x;
}

int triangle(int h,int b,float w)
{
   cout<<"base =";
   cin>>b;
   cout<<"height =";
   cin>>h;
   w=((b*h)/2);
   cout<<"Area ="w;
}
int quit()
{
   cout<<"Program Ends";
}

int main()
{
   int i;

cout<<"rectangle";

cout <<"circle";

cout<<"triangle";

cout<<"quit";


   switch(i)
    case 1: rectangle();
       break;
   case 2: circle();
       break;
   case 3: triangle();
       break();

   return;
}