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

I have to make a program that finds the radius of a cylinder when given Surface

ID: 3623069 • Letter: I

Question

I have to make a program that finds the radius of a cylinder when given Surface Area and height, this is a beginning class so we can only use "cout" commands .

here is what i got but i dont know what to do when i get a negative radius

#include "stdafx.h"

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
double SurfaceArea, Height, Radius1, Radius2, SquareRoot, P;

SurfaceArea = 18;
Height = 29;
P = -(SurfaceArea)/(2*3.14159);
SquareRoot = sqrt((Height*Height)-(4*P));

Radius1 = (-Height + SquareRoot)/2;
Radius2 = (-Height - SquareRoot)/2;

cout << " The Surface Area of the Cylinder = " << SurfaceArea
<< " ";
cout << " The Height of the Cylinder = " << Height
<< " ";
cout << " The Radius1 of the Cylinder = " << Radius1
<< " ";
cout << " The Radius2 of the Cylinder = " << Radius2
<< " ";

return 0;
}

Explanation / Answer

#include "stdafx.h" #include #include using namespace std; int main() { double SurfaceArea, Height, Radius1, Radius2, SquareRoot, P; SurfaceArea = 18; Height = 29; Radius1 = (-(2*3.14159*Height)+sqrt(4*3.14159*3.14159*Height*Height+8*3.14159*SurfaceArea))/4*3.14159; Radius2 = (-(2*3.14159*Height)-sqrt(4*3.14159*3.14159*Height*Height+8*3.14159*SurfaceArea))/4*3.14159; cout