MATCH OUTPUT AS IT IS WITH QUESTION OUTPUT ---------------------------------------------------------------- Write a C++ program to find the perimeter of different shapes based on the inputs using abstract classes. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. Consider a class named Shape with abstract method virtual double calculatePerimeter(). Consider a derived class named Circle derived from Shape with the following private member variables Data type Variable name double radius Include appropriate constructors, getters, and setters for the above class Consider a derived class named Rectangle derived from Shape with the following private member variables Data type Variable name double length double float Include appropriate constructors, getters, and setters for the above class Consider a derived class named Square derived from Shape with the following private member variables Data type Variable name double length Include appropriate constructors,getters and setters for the above class Implement the method calculatePerimeter() in all the derived classes to calculate appropriate perimeters. Note: Use 3.14 for pi value and display 2 digits after decimal in the answer. Input and Output format: Refer sample input and output for formatting specifications. [All Texts in bold corresponds to the input and the remaining corresponds to the output] Sample Input and Output 1: Select the shape: 1.Circle 2.Rectangle 3.Square 1 Enter the radius of the circle: 10 Perimeter of Circle is: 62.80 Sample Input and Output 2: Select the shape: 1.Circle 2.Rectangle 3.Square 2 Enter the length of the rectangle: 10.50 Enter the width of the rectangle: 11.50 Perimeter of Rectangle is: 44.00 Sample Input and Output 3: Select the shape: 1.Circle 2.Rectangle 3.Square 3 Enter the length of the square: 4.45 Perimeter of Square is: 17.80
MATCH OUTPUT AS IT IS WITH QUESTION OUTPUT
----------------------------------------------------------------
Write a C++ program to find the perimeter of different shapes based on the inputs using abstract classes.
Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.
Consider a class named Shape with abstract method virtual double calculatePerimeter().
Consider a derived class named Circle derived from Shape with the following private member variables
Data type | Variable name |
double | radius |
Include appropriate constructors, getters, and setters for the above class
Consider a derived class named Rectangle derived from Shape with the following private member variables
Data type | Variable name |
double | length |
double | float |
Include appropriate constructors, getters, and setters for the above class
Consider a derived class named Square derived from Shape with the following private member variables
Data type | Variable name |
double | length |
Include appropriate constructors,getters and setters for the above class
Implement the method calculatePerimeter() in all the derived classes to calculate appropriate perimeters.
Note: Use 3.14 for pi value and display 2 digits after decimal in the answer.
Input and Output format:
Refer sample input and output for formatting specifications.
[All Texts in bold corresponds to the input and the remaining corresponds to the output]
Sample Input and Output 1:
Select the shape:
1.Circle
2.Rectangle
3.Square
1
Enter the radius of the circle:
10
Perimeter of Circle is: 62.80
Sample Input and Output 2:
Select the shape:
1.Circle
2.Rectangle
3.Square
2
Enter the length of the rectangle:
10.50
Enter the width of the rectangle:
11.50
Perimeter of Rectangle is: 44.00
Sample Input and Output 3:
Select the shape:
1.Circle
2.Rectangle
3.Square
3
Enter the length of the square:
4.45
Perimeter of Square is: 17.80
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images