Question: Problem 2: C++ Define a class circle to implement the basic properties of a circle. The class circle should have one member variable radius of

Problem 2: C++

Define a class circle to implement the basic properties of a circle. The class circle should have one member variable radius of type double. The class should have the following member functions:

void setRaidus(double r)

double getRadius()

double area()

double circumference()

Create an object of class circle in your main function and test the member functions.

Formulas to calculate area and circle are the following:

Area of a Circle = 3.1416 * radius * radius

Circumference of a Circle = 2 * 3.1416 * radius

#include #include #include

using namespace std;

class Circle { private: double r = 10, getRadius(), area(), cicumference(); void Area(); void Circumference(); public: void setRadius(double r); double getRadius(); double area(); double circumference(); };

void getRadius { return r; }

void Area { double area = 3.1416 * (radius * radius); }

void Circumference { double circumference = 2 * 3.1416 * radius; }

void getCircumference { return Circumference; }

void getArea { return Area; }

int main() { Circle circle; cout << "Circumference: " << getCircumference; cout << "Area: " << getArea; return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!