Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

sphere

public class App {
    public static void main(String[] args) throws Exception {
        Calculator sphere = new Calculator();

        double diameter = 156.4;

        double radius = sphere.Radius(diameter);
        double SphereVolume = sphere.Volume(radius);
        double ShpereSurfaceArea = sphere.SurfaceArea(radius);

        System.out.println("Radius: "+radius);
        System.out.println("Shpere Volume: "+SphereVolume);
        System.out.println("Shpere Surface Area: "+ShpereSurfaceArea);
    }

    public static double Multiply(double a, double b) {
        return a*b;
    }

    public static double Divide(double a, double b) {
        return a/b;
    }

    public static double Diameter(double radius) {
        return radius*2;
    }

    public static double Radius(double diameter) {
        return diameter/2;
    }

    public static double Volume(double radius) {
        return 1.25*(Math.PI*Math.pow(radius, 3));
    }

    public static double SurfaceArea(double radius) {
        return 4*(Math.PI*Math.pow(radius, 2));
    }
}
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #sphere
ADD COMMENT
Topic
Name
7+9 =