In C++ language : A tank for propane gas is a cylinder with hemispheres at each
ID: 664665 • Letter: I
Question
In C++ language :
A tank for propane gas is a cylinder with hemispheres at each end. Write a program that will prompt the user to enter the length of the cylinder and the radius of the cylinder (same as the radius of the hemisphere and the units of the entered dimensions (the units will be the same for both the length and radius). The program should then calculate the volume of the tank by adding the volume contained the cylinder and the volume contained in the hemispheres. The output should include the length of radius of the tank as well as the volume.
The volume of a cylinder is given by the formula V = R2 L where R is the radius and L is the length of the cylinder. The volume of a hemisphere is given by 2/3(R3 ) where R is the radius. Your program should include a constant variable (declared constant) of 3.14159 for . You should run your program with test data, values for which you know the answer.
Explanation / Answer
#include<iostrem.h>
#include<conio.h>
main()
{
float r ,h ,volume1, volume2;
const float pi =3.14159;
cout<<"enter the radius:";
cin>>r;
cout<<"enter the length or height:";
cin>>h;
volume1 = pi*r*r*h;
cout<<"volume of cylinder is =<<"volume1;
volume2 = 2/3 *pi*r*r*r;
count<<" volume of hemispheres at the both ends of cylinder are given as =" <<2*volume2;
cout<<"total volume of the tank is given as "= << volume = volume1+volume2;
getch();
}
End
}