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

(java programming): given a cylinder with a half sphere on top and a cone on the

ID: 3624763 • Letter: #

Question

(java programming): given a cylinder with a half sphere on top and a cone on the bottom. Both the cylinder and cone have the same heigh and the base of both is a circle as well as the sphere on top. The volume of the half sphere is reduced by 10%. I need a program by entering the radius and height to find the total volume.
a. volume of cylinder is: area of sphere * cylinder height.
b. volume of sphere is: 4/3 * pi * (sphere radius) cubed.

c. volume of cone is: 1/3 * area of the cone's base * cone's height.

d. conversion from volume to bushels is 1 U.S. bushel = 2150.42 cu. in.

e. raising a number to a power use Math.pow(x,2) format.

f. approxmation of pi is Math.PI

g. be sure to run program and debugged if needed.

Explanation / Answer

import java.io.*;

public class Cylinder
{
public static void main(String args[])throws Exception
{
DataInputStream dis=new DataInputStream(System.in);
System.out.print("Enter Radius: ");
double radius=Double.parseDouble(dis.readLine());
System.out.print("Enter Height: ");
double height=Double.parseDouble(dis.readLine());

double areaOfSphere=4*Math.PI*Math.pow(radius,2);

double volumeOfCylinder=areaOfSphere*height;
double volumeOfSphere=4/3*Math.PI*Math.pow(radius,3);
double volumeOfCone=1/3*areaOfSphere*height;

System.out.println("Volume of the Sphere: "+volumeOfSphere+" cu. in.");
System.out.println("Volume of the Sphere: "+volumeOfSphere/2150.42 +" bushel");
System.out.println("Volume of the Cone: "+volumeOfCone+" cu. in.");
System.out.println("Volume of the Cone: "+volumeOfCone/2150.42 +" bushel");
System.out.println("Volume of the Cylinder: "+volumeOfCylinder+" cu. in.");
System.out.println("Volume of the Cylinder: "+volumeOfCylinder/2150.42 +" bushel");

}
}