Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Needs to be in C++. Perform the following steps under their corresponding //TODO comments inside main.cpp . Leave and //TODO comments be and don't delete

Needs to be in C++.

image text in transcribed

Perform the following steps under their corresponding //TODO comments inside main.cpp . Leave and //TODO comments be and don't delete them.

Define a scoped enumeration named ShapeKind whose possible values are: Circle, Square, and Rectangle.

Define a Shape structure with three members:

An enumerated variable named kind whose data type is the scoped enumeration ShapeKind defined in step 1.

Two double members named length and width representing the length and width of the square or rectangle shapes. For circles, the length and width are the same and represent the diameter of the circle.

Define a function with the prototype double area(Shape s); for calculating and returning the area of the shape.

Define a function with the prototype double perimeter(Shape s); for calculating and returning the perimeter of the shape.

Define a function that takes a single Shape argument and returns a string. Given a Shape object, this function returns a string representing its name ("Circle", "Square", or "Rectangle") based on the kind member of the shape structure . For example given a structure like this { ShapeKind::Circle, 10, 10 }, it returns the string "Circle". Here the prototype of this function:

string nameOf(Shape s);

Define a void-returning function named promptAndReadInputFor with a single Shape reference argument. Its prototype should be like void promptAndReadInputFor(Shape& shape);. Depending on the kind member of the Shape argument, this function prompts the user (using cout ) to enter and read the values (using cin ) of the following:

The length and width if the shape argument is a rectangle. If the entered length and width values happen to be the same, the shape argument's kind should be changed to ShapeKind::Square .

The length of a square if the shape argument is a square. Assign the entered value to both the length and width members of the shape argument.

The diameter of a circle if the shape argument is a circle. Assign the entered value to both the length and width members of the shape argument.

Inside the main() function, define two shape objects one for a square and the other for a rectangle. Initialize their lengths and widths to 0.0.

Inside the main() function, c all the promptAndReadInputFor() function on each of the circle object and the two shape objects of step 7.

Also inside the main() function, Use setw to output a report of the defined shapes in a table-like format similar to the outcome below.

After you finish this assignment, you will be able to do the following: - Define and use structures and enumerations - Prototype and define functions - Pass parameters to functions by value and reference - Format output with setw DESCRIPTION Replace the content of the src/main.cpp file with the following

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

Describe the team dynamics at Facebook.

Answered: 1 week ago

Question

Use service tiering to manage the customer base and build loyalty.

Answered: 1 week ago