Engineering Computations Project 1 This program will compute the volume and surf
ID: 3746595 • Letter: E
Question
Engineering Computations Project 1 This program will compute the volume and surface area of the following three geometric shapes: Sphere Cylinder Cone The formulas necessary to complete the calculations are available on the web Your program must include a narrative with suitable pseudocode and the main. The program should prompt the user for the radius and height of the three objects in inches (the same radius and height will be used for all three). The program should then clear the screen and output a formatted table identifying the original radius and height in inches and the volume and surface area of the three objects in the order sphere, cylinder, and then cone in inches cubed and inches squared respectively. The first column of the table should identify the object, the second column should identify the volume, and the third column should identify the surface area. Must include the following: Narrative Comments Formatting Compiles/Executes Input/Computation/Output UDF's (User Defined Functions) Error TrapsExplanation / Answer
below is the solution:
#include<iostream>
#include<math.h>
using namespace std;
//function prototype/declaration
float Volume_of_cylinder(int,int);
float Surface_Area_of_Cylinder(int,int);
float Area_of_Sphere(int);
float Volume_of_Sphere(int);
float Surface_Area_of_Cone(int, int);
float Volume_of_Cone(int, int);
int main()
{
int r,h,l; //radius,height,length input variable
//3.14 is pi value
cout<<"Enter radius and height of a sphere,cylinder and cone :"; //enter radius and height
cin>>r>>h;
//calculate cylinder volume and area
cout<<" Volume of cylinder is : "<<Volume_of_cylinder(r,h);
cout <<" Surface Area of Cylinder is : " << Surface_Area_of_Cylinder(r,h);
//calculate sphere volume and area
cout <<" Area of Sphere is : " << Area_of_Sphere(r);
cout <<" Volume of Sphere is : " << Volume_of_Sphere(r);
//calculate cone volume and area
l = sqrt(r * r + h * h); //length of a side of cone
cout<<" Surface Area of a Cone is : "<<Surface_Area_of_Cone(r,l);
cout<<" Volume of a Cone is : "<<Volume_of_Cone(r,h);
return 0;
}
//function definition
float Volume_of_cylinder(int r,int h){
return(3.14 * r * r * h);
}
float Surface_Area_of_Cylinder(int r,int h){
return(2 * 3.14 * r * (r + h));
}
float Area_of_Sphere(int r){
return(4 * 3.14 * r * r);
}
float Volume_of_Sphere(int r){
return(4 * 3.14 * r * r * r / 3);
}
float Surface_Area_of_Cone(int r, int l){
return(3.14 * r * (r + l));
}
float Volume_of_Cone(int r, int h){
return((1.0/3) * 3.14 * r * r * h);
}
output:
Enter radius and height of a sphere,cylinder and cone : 5 12
Volume of cylinder is : 942
Surface Area of Cylinder is : 533.8
Area of Sphere is : 314
Volume of Sphere is : 523.333
Surface Area of a Cone is : 282.6
Volume of a Cone is : 314
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.