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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started