Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ program Create a program that calculates the area of various shapes. If you are using IDE to develop this program, name your project (and

C++ program

Create a program that calculates the area of various shapes.

If you are using IDE to develop this program, name your project (and solution in VS2017) as Area to hold all files created. If you prefer to g++ and an editor without an IDE, save all files in a folder or directory also called Area.

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.

Submission

  • Either you use an IDE or g++ to complete this program, when finished, make a clean new folder or directory called Area and copy the following .h and .cpp files from your Area into this new place.
    • console.h
    • Shape.h
    • Circle.h
    • Rectangle.h
    • Square.h
    • console.cpp
    • main.cpp

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

The following information is from White Mountain Furniture Showroom

Answered: 1 week ago