Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++, write a program to calculate the area and perimeter of four simple plane figures: a rectangle, a circle, a square and a triangle.

Using C++, write a program to calculate the area and perimeter of four simple plane figures: a rectangle, a circle, a square and a triangle.

The program should begin by explaining itself to the user. It must then prompt the user for appropriate input (i.e: ask the user to select a rectangle, circle, square or triangle and then ask for necessary information based on the users selection). Next, the program must calculate and output the perimeter and area of the appropriate figure and then ask the user if he or she would like to find the perimeter and area of another figure.

We will assume all plane figures are measured in centimeters.

The program MUST take advantage of the concepts of Inheritance and Polymorphism.

A base class must be defined (you can call it whatever you like, but better has a meaningful name, such as PlaneFigure might be a good choice). Other classes (for example, Rectangle, Circle, Square and Triangle) must be derived from the PlaneFigure base class.

Also, two methods must be defined for the PlaneFigure class: perimeter and area. These methods are to be overridden for each derived class.

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

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions

Question

Are we being responsive to current business priorities?

Answered: 1 week ago

Question

2. How were various roles filled?

Answered: 1 week ago