Nbspcircle class write a class name circle with the class


Circle Class. Write a class name Circle, with the class declaration in a file called Circle.h and the implementation in a file called Circle.cpp. The class will have two data members, a double that holds the radius of the circle and a double called pi which will be set to the value, 3.14159 (data member cannot be set in the class declaration, pi should not be set via a parameter but set in the constructor). The class must provide the following member functions

  • Default Constructor - that sets the radius to 0.0
  • Constructor - that accepts the radius of the circle as an argument
  • setRadius - a mutator function for the radius variable
  • getRadius - an accessor function for the radius variable
  • getArea - calculates and returns (as double) the area of the circle using the formulaarea = pi * radius * radius
  • getDiameter - calculates and returns (as double) the diameter of the circle using the formuladiameter = radius * 2
  • getCircumference - calculates and returns (as double) the circumference of the circle using the formulacircumference = 2 * pi * radius

Write a program that demonstrates the Circle class by asking the user for the circle's radius and creating a Circle object and then reporting the circle's area, diameter and circumference. Two objects need to be created each using one of the two constructors (showing that both work along with the mutators and accessors).

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Nbspcircle class write a class name circle with the class
Reference No:- TGS01282292

Now Priced at $20 (50% Discount)

Recommended (90%)

Rated (4.3/5)