Main Class:
package cyldr;
public class CylinderTest
{
public static void main(String[] args)
{
Cylinder C = new Cylinder(); ///create a cylinder object
C.volume(); ///call the volume method
}
}
Cylinder Class:
package cyldr;
public class Cylinder
{
///set some value
int r = 5;
int h = 5;
void volume()
{
double R = Math.pow(r, 2);
System.out.println("Volume: " + (3.1416 * R * h));
}
}
Output
Volume: 392.69999999999993
Add your comment