Course Solutions Uncategorized (Solved) : C Make Class Generic Sides Shape May Integer Float Include Using Namespace Std Shape Squar Q34451316 . . . .

(Solved) : C Make Class Generic Sides Shape May Integer Float Include Using Namespace Std Shape Squar Q34451316 . . . .

 

C++

Make this class generic so that the sides of theshape may be integer or float

#include <iostream>
using namespace std;

// shape is square
class shape
{
int side;

public: int getSide()
{
return side;
}

bool setSides(int s)
{
if(s > 0)
{
side = s;
return true;
}
else
return false;
}

int getArea()
{
return side*side;
}

int getPerimeter()
{
return side*4;
}

void display()
{
cout<<“Side: “<<getSide()<<endl;
cout<<“Area: “<<getArea()<<endl;
cout<<“Perimeter: “<<getPerimeter();
}
};

int main()
{
shape S;
int num;

cout<<“Enter side: “;
cin>>num;

if(!S.setSides(num))
cout<<“Entered side is not validn”;

S.display();

return 0;
}

Expert Answer


An answer will be send to you shortly. . . . .

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

(Answered) : Part Ii 1 Find Domain Given Expression X2 3x 1 X2 5x 6 2 Simplify Following Expressions 4 Q28326061(Answered) : Part Ii 1 Find Domain Given Expression X2 3x 1 X2 5x 6 2 Simplify Following Expressions 4 Q28326061

<br/><img src="https://media.cheggcdn.com/media%2F6a4%2F6a46f86c-1e36-4c00-b5a0-10471cec759b%2Fimage" alt="Part II: 1. Find the domain of the given expression: x2 +3x +1 x2-5x +6 2. Simplify the following expressions: 4,,3,2 -14xyz 2,,6-5 2x2 -6x 6-2x b) a)