Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

=+2 Is the decision sustainable in the long run?

Answered: 1 week ago