Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Primarily using DEV C + + for doing coding. This is my code with correct output and the question is below the coding and the
Primarily using DEV C for doing coding.
This is my code with correct output and the question is below the coding and the sample output needed is given below.
#include
#include
using namespace std;
class Shapes
private:
int parameter parameter;
public:
Member function to accept inputs
void getParameters
cout "Enter the first parameterlength of a rectangle, or base of a triangle: ;
cin parameter;
cout "Enter the second parameterheight of a rectangletriangle: ;
cin parameter;
Member function to calculate area of rectangle
void rectangleArea
float area parameter parameter;
cout "Area of rectangle: area endl;
Member function to calculate area of triangle
void triangleArea
float area parameter parameter;
cout "Area of triangle: area endl;
;
int main
Create an object of the Shapes class
Shapes shapeObj;
Call member function to accept inputs
shapeObj.getParameters;
Use dowhile loop
do
string choice;
Read the shape choice from the user
cout "Select shape R for rectangle, and T for triangle: ;
cin choice;
If choice is R then call rectangleArea method
if choice R
shapeObj.rectangleArea;
If choice is T then call triangleArea method
else if choice T
shapeObj.triangleArea;
Else print Invalid message
else
cout "Invalid choice." endl;
while true; Infinite loop, user can exit as per their choice
return ;
QUESTION.
Implement a new derived class called ShapesExtendmarks
This class should inherit from the base class Shapes that you have designed before.
In this class, implement additional methods to check for the input values. If the values are equal, and the choice for shape is a rectangle, then modify the output to Area of square is
Sample Output:
Enter the first parameter length of a rectangle, or base of a triangle:
Enter the second parameter height of a rectangletriangle:
Select shape R for rectangle, and T for triangle: C Invalid choice.
Select shape R for rectangle, and T for triangle: R
Area of the square is
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started