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

Write static methods 1.1 public static double cubeVolume(double h) 1.2 public st

ID: 3760767 • Letter: W

Question

Write static methods 1.1 public static double cubeVolume(double h) 1.2 public static double cubeSurface(double h) 1.3 public static double sphereVolume(double r) 1.4 public static double sphereSurface(double r) 1.5 public static double cylinderVolume(double r, double h) 1.6 public static double cylinderSurface(double r, double h) 1.7 public static double coneVolume(double r, double h) 1.8 public static double coneSurface(double r, double h) that compute the volume and surface area of a cube with height h, sphere with radius r, a cylinder with circular base with radius r and height h, and a cone with circular base with radius r and height h. Place them into a class Geometry. Then write a program that prompts the user for the values of r and h, calls the six methods, and prints the results. also second question Solve Exercise 1 by implementing classes: 2.1 Cube 2.2 Sphere 2.3 Cylinder 2.4 Cone

Explanation / Answer

import java.io.*;
import java.util.*;
class Geometry
{
public static double cubeVolume(double h)
{
return Math.pow(h,3);
}
public static double cubeSurface(double h)
{
return 6 * h * h;
}
public static double sphereVolume(double r)
{
return 4.0/3 * Math.PI * Math.pow(r,3);
}
public static double sphereSurface(double r)
{
return 4.0 * Math.PI * r * r;
}
public static double cylinderVolume(double r, double h)
{
return Math.PI * r * r * h;
}
public static double cylinderSurface(double r, double h)
{
return 2 * Math.PI * r * h + 2 * Math.PI * r * r;
}
public static double coneVolume(double r, double h)
{
return Math.PI*Math.pow(r,2)*h/3.0;
}
public static double coneSurface(double r, double h)
{
return Math.PI*r*(r+Math.sqrt(h*h + r*r));
}
public static void main(String[] args)
{
System.out.print("Enter the radius: ");
Scanner sc = new Scanner(System.in);
double radius, height;
radius = sc.nextDouble();
System.out.print("Enter the height: ");
height = sc.nextDouble();
System.out.println("Volume of a Cube: "+cubeVolume(height));
System.out.println("Surface area of a Cube: "+cubeSurface(height));
System.out.println("Volume of a Sphere: "+sphereVolume(radius));
System.out.println("Surface area of a Sphere: "+sphereSurface(radius));
System.out.println("Volume of a Cylinder: "+cylinderVolume(radius, height));
System.out.println("Surface area of a Cylinder: "+cylinderSurface(radius, height));
System.out.println("Volume of a Cone: "+coneVolume(radius, height));
System.out.println("Surface area of a Cone: "+coneSurface(radius, height));
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote