title: Function isn't calculating correctly?
body: <p>After creating three objects it is supposed to take the radius and height from the user, calculate the volume and then ask again for the next cylinder. When I run this code it does prompt me for the radius and height, but it does not calculate the volume. What am I doing wrong?</p>
  
  <pre><code>import javax.swing.JOptionPane;
  import java.io.*;
  
  
  public class CylinderTest 
  {
  public static void main(String[] args) throws IOException
  {
      String input;
      String input2;
      double radius[] = new double[3];
      double height[] = new double[3];
      Cylinder[] myCylinder = new Cylinder[3];
  
  
  
          for (int i = 0; i &lt; myCylinder.length; i++)
          {
  
               input = JOptionPane.showInputDialog("Enter a radius");
                  radius[ i ] = Double.parseDouble(input);
                  input2 = JOptionPane.showInputDialog("Enter a height" +
                          "");
  
  
                  height[i] = Double.parseDouble(input2);
  
                  myCylinder[i].height = input2;
                  myCylinder[i].radius = input;
  
                  JOptionPane.showMessageDialog(null, " The volume of the cylinder is: " + myCylinder.getVolume());       
              }
  
      }
  
  
  
  
  
  
  
  static class Cylinder
  {
  private double radius;
  private double height;
  
  
  public  Cylinder(double radius, double height)
       {      this.radius = radius;
              this.height = height;
  
  }
  
  
  
  public double getVolume()
  {
  
      return radius * radius * height * Math.PI;
  
  
  }
  }
  
  }
  </code></pre>