Cylinder.java

Cylinder.java

Create a class called Cylinder.java that contains two double-precision instance variables named radius and height. The class should include a constructor that initializes the radius and height variables. Also, you need a class method named volume() that returns the volume of a Cylinder object. The volume of a cylinder is given by its radius squared times its height times Pi (radius * radius * height * Math.PI). You can either use the value 3.1416 for Pi or use the Java provided value named Math.PI.

Write a class called CylinderTest.java and declare an array of three Cylinder objects to call the methods you declared in the Cylinder class. Make sure that all class methods are called from main(). Have main() display the value returned by volume() and verify the returned value by hand calculations (paper/pencil). Prompt the user to enter the values for the radius and height of each Cylinder object in the array.

View Answers









Related Tutorials/Questions & Answers:
Cylinder.java
Cylinder.java  Create a class called Cylinder.java that contains two double-precision instance variables named radius and height. The class should include a constructor that initializes the radius and height variables. Also, you
cylinder.java - Java Beginners
cylinder.java  the java program that calculate cylinder.  Hi friend, import java.io.*; import javax.swing.*; import javax.swing.JOptionPane; public class CylinderTest { public final static double PI
Advertisements
Java - Java Beginners
Java  I've been trying to figure out this program but I keep getting errors and its not working out. Can someone help me? this is the program Create a class called Cylinder.java that contains two double-precision instance

Ads