Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the following problem listed below using the C++ programming language.

ID: 649745 • Letter: C

Question

Complete the following problem listed below using the C++ programming language.

1) Define a class to represent circle. Data members should include radius, circumference, area. Member functions should allow the following: ? A constructor to initialize its data members i.e radius ? A function to calculate area of the circle ? A function to calculate circumference of the circle.

In your program radius should have public access. The value for radius should be initialized externally through a constructor. Circumference and area Should have private access. Then create an object for class circle and implement the above function members.

Explanation / Answer

include <iostream>
using namespace std;

class circle
{

private:
double circumference,area;

public:
int radius;
//circumference, area;
// Member functions should allow the following:
// constructor to initialize its data members i.e radius
circle()
{radius=9;
}
circle(int r)
{
radius=r;
}
// function to calculate area of the circle
double area1()
{
area=3.14*radius*radius;
return area;
}
// function to calculate circumference of the circle

double circumference1 ()
{
circumference =2*3.14*radius;
return circumference;
}

};


int main() {
   double ar,cir;
circle c(8);
ar=c.area1();
cir=c.circumference1();
cout<<"circle "<<cir;
cout<<"circle "<<ar;


   // your code goes here
   return 0;
}

output

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote