Write this program using C++ programming language. In the addition to the above
ID: 3663204 • Letter: W
Question
Write this program using C++ programming language.
In the addition to the above member functions, provide the following:
copy constructor - Accepts a Circle as it's argument, and initializes the circle with the argument's radius
operator= - assigns the radius of one circle to the other
operator< - returns true if the left-hand side circle has a radius less than the right-hand side, false otherwise.
operator== - returns true if both circles have the same radius, false otherwise.
operator+ - returns a circle with a radius that is the sum of the two circles added together.
operator++ - increments the radius of the circle by 0.1. ( pre- and post-fix versions )
operator<< - sets the radius of the circle
operator>> - retrieves the radius of the circle
Place the circle class, and only this circle class, in it's own header file named Circle.h. Submit this header file ONLY.
Hints:
Use the circle.cpp file attached to get you started on testing the class. It is not a complete test driver, but can get you started.
Write the "blue" part of the assignment first. Then, once you've tested that and are sure it's working, make a backup copy. Then Add the additional constructor and overloaded methods.
Write and test one method at a time, using your own test driver!
Circle.cpp:
Explanation / Answer
Public class circle{
Private Final Double Pi=3.14159
Private double radius
Public circle(){
Radius=0.0;
}
public circle (double r){
radius=r;
}
public void set radius(double r){
radius=r;
}
public double get radius(){
Return radius;
}
public double get area(){
Return Pi* radius*radius;
}
public double get diameter(){
Return radius*2;
}
public double get circumfrence(){
return2*Pi*radius;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.