我有一个家庭作业,我从用户那里获取圆柱的半径和高度的输入,然后返回体积。我认为我已经完成了大部分工作,但无法将它们整合在一起。当我尝试将其全部打印出来时出现语法错误。这是打印线
for (int i = 0; i < volume.length; i++)
{
System.out.println("for Radius of:" + volume[i].getRadius() + " and Height of:" + volume[i].getHeight() + " the Volume is:" + volume.getVolume());
}
Run Code Online (Sandbox Code Playgroud)
这是主类
import javax.swing.*;
//Driver class
public class CylinderTest
{
public static void main(String[] args)
{
Cylinder[] volume = new Cylinder[3];
for (int counter = 0; counter < volume.length; counter++)
{
double radius = Double.parseDouble(JOptionPane
.showInputDialog("Enter the radius"));
double height = Double.parseDouble(JOptionPane
.showInputDialog("Enter the height"));
volume[counter] = new Cylinder(radius, height); …Run Code Online (Sandbox Code Playgroud)