I am learning how to create classes, and I had to create a class with a program to

test it that finds the volume and surface area of a sphere, cylinder, and cone.

I am having some problems- for my cone Volume, it is returning everything as 0. For the program, I have

counter = 1;

System.out.println("Cone Volume");

while (counter <= 10)

{

double radius = Math.random();

System.out.println("Radius: " + radius);

double h = Math.random();

System.out.println("H: " + h);

double coneVolume = yourTurnClass.coneVolume(radius,h);

System.out.println("answer: " + coneVolume);

counter++;

}

________

For the class I have:

public static double coneVolume(double radius, double h)

{

answer = (1/3*((Math.PI)*((radius*radius)*(h))));

return answer;

}

_________

Am I messing something up with pi?

Another problem I have is with coneSurface- I have formula:

public static double coneSurface(double radius, double h)

{

answer = (Math.PI*(radius*(Math.sqrt(h*h + radius*radius) + radius*radius)));

return answer;

}

and program

while (counter <= 10)

{

double radius = Math.random();

System.out.println("Radius: " + radius);

double h = Math.random();

System.out.println("H: " + h);

double coneSurface = yourTurnClass.coneSurface(radius,h);

System.out.println("answer: " + coneSurface);

counter++;

}

and my answers are coming out a bit off. Did I miss my formula up, or call something wrong?

My final problem is with the sphere volume- I have class

public static double sphereVolume(double radius)

{

answer = ((4/3)*(Math.PI)*(radius*radius*radius));

return answer;

}

and program

while (counter <= 10)

{

double radius = Math.random();

System.out.println("Radius: " + radius);

double sphereVolume = yourTurnClass.sphereVolume(radius);

System.out.println("answer: " + sphereVolume);

counter++;

}

_______

with answers slightly wrong again. Is there something I am doing wrong that is the same with all three of these?

THANK YOU SO MUCH FOR YOUR HELP!!!