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

write these three functions: 1) getRadius This function should ask the user to e

ID: 654659 • Letter: W

Question

write these three functions:

1) getRadius

This function should ask the user to enter the value for the radius and return that value.

2) findArea

This function should take the radius as a parameter and calculate and return the area.

(Hint: area = 3.14159*radius*radius)

3) findCircumference

This function should take the radius as a parameter and calculate and return the circumference.

(Hint: circumference = 2*3.14159*radius)

OPTIONAL: Use prototypes for your functions. Place the prototypes before main (but after the using

namespace std; line) and place the actual functions after the main function.

Then write C++ program to get following sample run.

A sample run of your program should look like this (bold bracketed text stands for user input):

Enter the radius of the circle: [3.5]

A circle of radius 3.5 has an area of: 38.4845

and a circumference of: 21.9911

Explanation / Answer

#include <cstdlib>

#include <iostream>

using namespace std;

#include <iostream.h>

#include <math.h>

const double PI = 3.14159;

//class interface (definition)

class Circle

{

public;

// constructors

Circle(); // default constructor

Circle(const circle &); // copy constructor

// member functions (methods)

void SetRadius(double); // modifier that sets new radius

double Area();

private;

// member variables (data)

double radius; // circle's radius

};

int main()

{

double radius;

double circumference;

double area;

Circle myCircle; // circle object used as an example

double circleArea = 38.4845; // area of the circle

double userInput = 0.0; // user input for radius of circle

cout << "Enter radius of the circle: ";

cin >> userInput;

myCircle.SetRadius(userInput);

circleArea = myCircle.Area();

cout << "The area is " << circleArea << end1 << end1;

return 0;

}// end of main

// class implementation

// default constructor

Circle::Circle()

{

radius = 0.0;

}

// copy constructor

Circle :: Circle(const Circle & object)

{

radius = Object.radius;

}

// sets the radius of the circle

void Circle :: SetRadius(double IncomingRadius)

{

radius = IncomingRadius;

}

// computes the area of the circle

double Circle :: Area()

{

return (PI*pow(radius, 2));

}