Ask the user to input a radius using the following text: Ask the user to input a
ID: 3528228 • Letter: A
Question
Ask the user to input a radius using the following text:
Ask the user to input a height using the following text:
Write code to calculate:
The surface area of a cylinder with the given radius and height
The volume of a cylinder with the given radius and height
The surface area of a cone with the given radius and height
The volume of a cone with the given radius and height
Print the calculated surface area of the cylinder using the following text:
Print the calculated volume of the cylinder using the following text:
Print the calculated surface area of the cone using the following text:
Print the calculated volume of the cone using the following text:
Explanation / Answer
#include using namespace std; int main () { //Declares pi, r, h, volumecone. float r, h, surfaceAreaCylinder,volumeCylinder,coneS,surfaceAreaCone,volumeCone; float pi = 3.14159; //User inputs radius. cout > r; //User inputs height. cout > h; //Calculates surface area of cylinder surfaceAreaCylinder = (2*(pi*(r*r))+2*pi*h); //Calculates volume of the cylinder volumeCylinder = (pi*(r*r)*h); // surface area of cone coneS = // DO YOU HAVE ACCESS TO math.h ?? if not square roots could be a bit tricky surfaceAreaCone = //Caculates the cone's volume. volumeCone = (1.0/3.0) * pi * (r*r) * h; //Output to screen. coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.