Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

%3Cp%20class%3D%22c1%22%3EImplement%20a%20class%20called%20Cone%20with%20methods

ID: 3552036 • Letter: #

Question

%3Cp%20class%3D%22c1%22%3EImplement%20a%20class%20called%20Cone%20with%20methods%0AgetSurfaceArea()%20and%20getVolume().%20For%20the%20surface%20area%2C%3C%2Fp%3E%0A%3Cp%20class%3D%22c1%22%3Einclude%20the%20base%20of%20the%20cone%20in%20the%20area%20calculation.%0AInclude%20a%20constructor%20that%20takes%20the%20can's%20height%20and%3C%2Fp%3E%0A%3Cp%20class%3D%22c1%22%3Eradius%20as%20parameters.%20Also%20include%20a%20constructor%20that%0Atakes%20no%20parameters.%20Make%20this%20constructor%20call%20the%3C%2Fp%3E%0A%3Cp%20class%3D%22c1%22%3Econstructor%20with%20two%20parameters%2C%20passing%20a%20value%20of%0A1.0%20for%20the%20radius%20and%202.0%20for%20the%20height.%20For%20the%3C%2Fp%3E%0A%3Cp%20class%3D%22c1%22%3Esurface%20area%2C%20include%20the%20base%20of%20the%20cone%20in%20the%0Aarea%20calculation.%3C%2Fp%3E%0A

Explanation / Answer

class Cone

{

float radius, height;

Cone(float r, float h)

{

radius=r;

height=h;

}

Cone()

{

Cone(1.0,2,0);

}

float getSurfaceArea()

{

return (3.14*r*(r + sqrt((h*h)+(r*r))))

}

float getVolume()

{

return ((1/3)*3.14*r*r*h)

}

}