Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// 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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

How to Choose the Sample Size

Answered: 1 week ago