Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a program that calculates the area of various shapes. Console Specifications Create an abstract class named Shape . This class should contain virtual member
Create a program that calculates the area of various shapes.
Console
Specifications
- Create an abstract class named Shape. This class should contain virtual member function named get_area() that returns a double type.
- Create a class named Circle that inherits the Shape class and contains these constructors and member functions:
- Circle(double radius)
- double get_radius()
- void set_radius(double radius)
- double get_area()
- Create a class named Square that inherits the Shape class and contains these constructors and member functions:
- Square(double width)
- double get_width()
- void set_width(double width)
- double get_area()
- Create a class named Rectangle that inherits the Square class and contains these constructors and member functions:
- Rectangle(double width, double height)
- double get_height()
- void set_height(double height)
- double get_area()
- Use the following formulas to calculate area:
- Circle: Area = radius2 * pi
- Square: Area = width2
- Rectangle: Area = width * height
- In the main.cpp class, use a function named display_area() to display the area of each shape.
- Use the console namespace presented in chapter 7, p.274~277, to get and validate the users entries.
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