Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some help with my script please. #include using namespace std; double pi = 3.14; class Circle { private: double radius; public: Circle(); {

image text in transcribed

I need some help with my script please.

#include

using namespace std;

double pi = 3.14;

class Circle {

private:

double radius;

public:

Circle(); {

radius = 1;

}

Circle(double r) {

radius = r;

}

void setRadius(double r) {

radius = r; {

if (radius != 1)

throw invalid_argument("Invalid value for radius");

else

setRadius(r);

}

}

double getRadius() {

return radius;

}

double getArea() {

return pi * radius*radius;

}

double getDiameter() {

return 2 * radius;

}

double getCircumference() {

return 2 * pi*radius;

}

};

int main() {

Circle c1;

double r;

cout

cout

cout

cout

cout

cin >> r;

c1.setRadius(r);

cout

cout

cout

cout

circle c2(-1);

cout

cout

cout

cout

return 0;

}

Define the class Circle. The Circle class has a private data member radius (double) Define constructors for the Circle class. Include set and get functions for the radius data member. Include a function called area that returns the area of the Circle Overload the operator

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

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions

Question

Lo6 Identify several management development methods.

Answered: 1 week ago