Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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.
The Area Calculator Circle, square, or rectangle? (c/s/r): c Enter radius: 15 Area: 706.858 Continue? (y): y circle, square, or rectangle? (c/s/r):r Enter width 15 Enter height: 20 Area: 300 continue? (y): n Bye

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions