Question: // Please follow the instructions and solve it by C++. Please and thank you!! Part1: Convert the following code into a Cylinder Class. The class

// Please follow the instructions and solve it by C++. Please and thank you!!

Part1: Convert the following code into a Cylinder Class.

The class must have two methods:

init(r,h) to initialize the cylinder's radius/height

getVolume() to get its volume

Part2: Show how to convert the main() function so it uses your new class

///////// Code /////////

double getVolume(int r, int h)

{

const double pi= 3.1415926535;

double vol= pi*r*r*h;

return vol;

}

int main()

{

int radius; // define the attributes

int height; // of a cylinder

radius = 10; // init radius and height

height = 20;

double v = getVolume(radius,height);

cout << " The volume is: "" << v;

}

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!