Boy, where to begin...
#1
Code:
class circle
{
...
void caclulateArea();
void calculateCircumference();
void displayOutput();
void setRadius(); //mutator
int getRadius(int userRadius); //accessor
};
...
void calculateArea(int radius,const double PI)
{
...
}
...
void calculateCircumference(int radius, const double PI)
{
...
}
...
void displayOutput(int radius, int area, int circumference)
{
...
}
...
int circle::getRadius(int userRadius)
{
...
}
...
void circle::setRadius()
{
...
}
You manage to set up the setRadius and getRadius functions correctly by indicating they are a part of the circle class but you neglect to do so with the calculateArea, calculateCircumference and displayOutput functions? Those both need circle:: in front of the function names.
#2
Code:
class circle
{
private:
int radius;
int circumference;
int area;
...
};
...
void calculateArea(int radius,const double PI)
{
double area = pow (radius * PI, 2);
}
...
void calculateCircumference(int radius, const double PI)
{
double Circumference = (radius * PI * 2);
}
...
void displayOutput(int radius, int area, int circumference)
{
cout << "Using " << radius << " as the radius" << endl;
cout << "The area would be " << area << endl;
cout << "The circumference would be " << circumference << endl;
}
...
int circle::getRadius(int userRadius)
{
cout << "This program will calculate the area and circumference of " << endl;
cout << "a circle based off of the radius using a class." << endl;
cout << "Enter the radius --> " << endl;
cin >> radius;
return userRadius;
}
...
void circle::setRadius()
{
int radius = 0;
int userRadius = radius;
}
Your class has member variables. Use them! Most of your member functions take arguments that are unnecessary - you should not have to pass in a radius, area, circumference values to these functions since they should just be able to access the class's own variables. The constant PI should be defined as such somewhere at the beginning of the program as a global and not in main, it therefore also does not need to be passed into the functions.
You use local variables in your member functions with the same/different names as the class's own member variables but the local ones will hide the class's ones and changes to the locals will therefore not affect the class variables. The only place you appear to do this correctly (somewhat) is in your getRadius function where you reference the member variable radius (why are you returning the same value you pass in). Everywhere else, you have locals that simply get a value assigned and then are immediately thrown away as they are popped off the stack when the functions end - this is pointless.
#3 Design issues - Your current class design depends on the calculateArea, calculateCircumference functions being manually called after each update to the radius. It would be better for these functions to be called automatically within whatever setRadius function you wind up with such that when the radius gets updated, the new circumference and area values are updated along with it instead of relying on you manually calling the relevant functions.
If your getRadius function is an accessor as you claim then it should simply return the current radius value stored in the class. I/O does not seem appropriate in such a function. It does not need an argument passed into the function, simply return radius (and don't declare a new local radius variable). As such this function should probably be declared const since it would not then be a function that modifies the class.
The setRadius function should either accept a value which holds the new desired radius - to which the classes radius variable gets set - or it should query the user and accept a new value through cout/cin.
...probably other stuff but that's it for now.