Question: Convert problems in to template classes. Test each with Implicit int, float, double, long int. Test each with explicit int, float, double, long int. Please

Convert problems in to template classes.

Test each with Implicit int, float, double, long int.

Test each with explicit int, float, double, long int.

Please help me with this C++ problem

Q.

//Main.cpp

#include

#include "Circle.h"

using namespace std;

int main()

{

double radius = 0;

cout << "Enter radius of circle: ";

cin >> radius;

//declare Circle class

Circle c;

c.setRadius(radius);

cout << "Radius:" << c.getRadius()<< endl;

cout << "Circumference:" << c.calcCircumference() << endl;

cout << "Area:" << c.calcArea() << endl;

cout << "Diameter:" << c.calDiameter() << endl;

system("pause");

return 0;

}

---------------------------------------------------------

//Circle.cpp

#include

#include "Circle.h"

using namespace std;

//Default constructor

Circle::Circle()

{

radius=0;

}

//Parameterized constructor

Circle::Circle(double r)

{

radius=r;

}

//Setter methods

void Circle::setRadius ( double r )

{

radius=r;

}

//Getter method

double Circle::getRadius ( )

{

return radius;

}

double Circle::calcCircumference()

{

return 2 * 3.14 * radius;

}

double Circle::calcArea ()

{

return 3.14 * radius * radius;

}

double Circle::calDiameter()

{

return 2 * radius;

}

-------------------------------------

//Circle.h

#include

using namespace std;

class Circle

{

public:

double radius;

public:

//Default constructor

Circle();

//Parameterized constructor

Circle(double );

//Setter methods

void setRadius ( double n ) ;

//Setter methods

double getRadius () ;

//Methods to calculate area and volume of box

double calcCircumference() ;

double calcArea () ;

double calDiameter();

};

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!