Question & Answer: Write a class definition called Circle that stores an instance variable named radius for the radius of the circle as float. Write…..

Write a class definition called Circle that stores an instance variable named radius for the radius of the circle as float. Write the corresponding getter and setter methods (getRadius, setRadius), and a constructor that takes a float parameter for the radius of the circle.

Include both the class declaration and method definitions! Be sure to use appropriate visibility modifiers.

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: Write a class definition called Circle that stores an instance variable named radius for the radius of the circle as float. Write…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

Assume all includes and using namespace std are already in the file. Do not try to make header files.

Expert Answer

 

#include <iostream>
#include <string>
using namespace std;
class circle{
private:
double radiuss;
public:
circle(double rad) {
radiuss=rad;

}
circle(){
radiuss=0;
}

double get_radius() {
return radiuss;
}

void set_radius(double rad){
radiuss=rad;
}

double get_area() {
return radiuss*radiuss*3.14;
}
};
int main()
{
circle c1(1.1);
c1.set_radius(1.4);
cout<<“radius of circle is:”<<c1.get_area();

return 0;
}

output:

Question & Answer: Write a class definition called Circle that stores an instance variable named radius for the radius of the circle as float. Write..... 1

/* constructor with parameter and constructor withoout parameters are written and getters and setters and area method is implemented
*/

Still stressed from student homework?
Get quality assistance from academic writers!