Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Class: Name: Circle Purpose: To accept and store the data for a circle and to provide functions that will manipulate the data. Constructor: Zero -

Class:
Name: Circle
Purpose: To accept and store the data for a circle and to provide functions that will manipulate the data.
Constructor:
Zero-argument constructor that initializes the data members to. Data Members:
radius int Must be 1.0 or greater.
colorFill string Cannot be blank.
Functions:
calcDiameter()- double Calculates and returns the diameter of the circle. The diameter is a double.
calcArea()- double Calculates and returns the area of the circle. The area is a double.
calcCircumference()- double Calculates and returns the circumference of the circle. The circumference is a double.
setRadius()- void Accepts a radius value and updates the radius data member.
getRadius()- int Returns the value stored in the radius data member.
setColorFill()- void Accepts the fill color value and updates the colorFill data member.
getColorFill()- string Returns the value stored in the colorFill data member.
Note: Setters and Getters are required even if they are not used.
Non-Class Functions:
displayCircleInfo() void Creates and displays the formatted output of the book shipment information. Do a Google search for C++ setw(), left, right for how to use these functions/commands to create easy to read formatted output.
Formulas:
Note: The calc functions are returning a double, and the radius is an integer. The simplest way to convert an int to a double is to multiply the radius by 1.0. Example: double myDiameter; myDiameter =(getRadius *1.0)*2;
Area = Pi * radius squared For Pi, use the value of 3.14 so your results will match mine. You can make this a const using the following line of code in the Circle.cpp file above the constructor const double PI =3.14; Data Members:
radius int Must be 1.0 or greater.
colorFill string Cannot be blank.
Functions:
calcDiameter()- double Calculates and returns the diameter of the circle. The diameter is a double.
calcArea()- double Calculates and returns the area of the circle. The area is a double.
calcCircumference()- double Calculates and returns the circumference of the circle. The circumference is a double.
setRadius()- void Accepts a radius value and updates the radius data member.
getRadius()- int Returns the value stored in the radius data member.
setColorFill()- void Accepts the fill color value and updates the colorFill data member.
getColorFill()- string Returns the value stored in the colorFill data member.
Note: Setters and Getters are required even if they are not used.
Non-Class Functions:
displayCircleInfo() void Creates and displays the formatted output of the book shipment information. Do a Google search for C++ setw(), left, right for how to use these functions/commands to create easy to read formatted output.
Formulas:
Note: The calc functions are returning a double, and the radius is an integer. The simplest way to convert an int to a double is to multiply the radius by 1.0. Example: double myDiameter; myDiameter =(getRadius *1.0)*2;
Area = Pi * radius squared For Pi, use the value of 3.14 so your results will match mine. You can make this a const using the following line of code in the Circle.cpp file above the constructor const double PI =3.14;
For radius squared, use the pow() function instead of getRadius()* getRadius() Example: pow(4,2) is 4 squared where 4 is the value of the radius, and 2 is the power to raise the radius to, in this case, squared. Use the getRadius() function to get the radius value.
Circumference =2* PI * radius
Diameter =2* radius
The class should use appropriate protection levels for the member data and functions. Data members must be in the private: section. It must also follow principles of minimalization: that is, no data member should be part of a class unless most functions of the object need it. A general rule of thumb is that if you can easily calculate it, dont store it.
Program Flow:
Start a loop that goes until the user enters -1 for the radius.
Create the Circle object using the zero argument constructor.
Prompt the user for the radius. If the user enters -1, exit the loop, otherwise, update the Circle object with the value entered.
Prompt the user for the fill color and update the Circle object with the value entered.
Display the Circle information using a separate function. This function will call the Circle object functions defined in the class.
Pause the display so the user can read the displayed information.
Your program should allow the user to enter new circle radius until the user enters -1 for the radius. Be sure to include appropriate error checking. Does it make sense to enter abc as the radius of a circle? No. Therefore, you should ensure the user enters numeric data for the side. Negative numbers (other than the

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_2

Step: 3

blur-text-image_3

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

Database And Expert Systems Applications Dexa 2023 Workshops 34th International Conference Dexa 2023 Penang Malaysia August 28 30 2023 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Maqbool Khan

1st Edition

303139688X, 978-3031396885

More Books

Students also viewed these Databases questions