
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
Edition 8ISBN: 978-1285867410
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
Edition 8ISBN: 978-1285867410 Exercise 7
Creating a Class in C++
In this exercise, you use what you have learned about creating and using a programmer-defined class. Study the following code, and then answer Questions.
class Circle{public:void setRadius(double);double getRadius();double calculateCircumference();double calculateArea();private:double radius; // Radius of this circleconst double PI = 3.14159;};void Circle::setRadius(double rad){radius = rad;}double Circle::getRadius(){return radius;}double Circle::calculateCircumference(){return (2 * PI * radius)}double Circle::calculateArea(){return(PI * radius * radius)}
In the following exercise, assume that a Circle object named oneCircle has been created in a program that uses the Circle class, and radius is given a value as shown in the following code:
Circle oneCircle;oneCircle.setRadius(4.5);
Write the C++ code that will assign the circumference of oneCircle to a double variable named circumference1.
In this exercise, you use what you have learned about creating and using a programmer-defined class. Study the following code, and then answer Questions.
class Circle{public:void setRadius(double);double getRadius();double calculateCircumference();double calculateArea();private:double radius; // Radius of this circleconst double PI = 3.14159;};void Circle::setRadius(double rad){radius = rad;}double Circle::getRadius(){return radius;}double Circle::calculateCircumference(){return (2 * PI * radius)}double Circle::calculateArea(){return(PI * radius * radius)}
In the following exercise, assume that a Circle object named oneCircle has been created in a program that uses the Circle class, and radius is given a value as shown in the following code:
Circle oneCircle;oneCircle.setRadius(4.5);
Write the C++ code that will assign the circumference of oneCircle to a double variable named circumference1.
Explanation
Program plan:
• Define a class named "C...
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
Why don’t you like this exercise?
Other Minimum 8 character and maximum 255 character
Character 255