Write a single class that has the methods: public static double sphereVolume(dou
ID: 3930505 • Letter: W
Question
Write a single class that has the methods: public static double sphereVolume(double r) public: static double sphereSurface(double r) public static double coneVolume(double r, double h) public static double coneSurface (double r, double h) Then write a main ( ) method that prompts the user for values for r (radius) and h (height) and calls all of the other methods to displays the results. Your main ( ) method takes care of all input collection and printing of the results - make of the method arguments and return values. You do not need to do any error checking on the input values. C:UsersaronDesktopjava SphereAndCone Enter a value for radius:1 Enter a value for height:1 Sphere Volume: 4.1887902047863905 Sphere Surface Area: 12.566370614359172 Cone Volume: 1.0471975511965976 Cone Surface Area: 7.584475591748159 C: UsersaronDesktopjava SphereAndCone Enter a value for radius:5.5 Enter a value for height:12.2 Sphere Volume: 696.9099703213358 Sphere Surface Area: 380.132711084365 Cone Volume: 386.46825626910436 Cone Surface Area: 326.26533476656/43Explanation / Answer
import java.util.Scanner;
import javax.jws.soap.SOAPBinding;
import javax.swing.SortingFocusTraversalPolicy;
public class SphereAndcone {
public static double sphereVolume(double r){
return ((4/3)*3.14*r*r*r);
}
public static double sphereSurface(double r){
return (4*3.14*r*r);
}
public static double coneVolume(double r,double h){
return (3.14*r*r*(h/3));
}
public static double coneSurface(double r,double h){
return (3.14*r(r+Math.sqrt((h*h)+(r*r))));
}
public static void main(String a[]){
Scanner user_input = new Scanner( System.in );
double rad;
double hig;
System.out.println("enter the radious");
rad=user_input.nextDouble();
System.out.println("enter the height");
hig=user_input.nextDouble();
System.out.println(sphereVolume(rad));
System.out.println(sphereSurface(rad));
System.out.println(coneVolume(rad,hig));
System.out.println(coneSurface(rad, hig));
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.