```java class Rectangle { double length; double width; double calculateArea() { return length * width; } } class Cuboid extends Rectangle { double height; double calculateVolume() { return calculateArea() * height; } } public class Test { public static void main(String[] args) { double length = Double.parseDouble(args[0]); double width = Double.parseDouble(args[1]); double height = Double.parseDouble(args[2]); Cuboid cuboid = new Cuboid(); cuboid.length = length; cuboid.width = width; cuboid.height = height; System.out.println("这是体积计算:" + cuboid.calculateVolume()); System.out.println("这是底面积计算:" + cuboid.calculateArea()); System.out.println("另一种实例化方式:"); Rectangle rectangle = new Rectangle(); rectangle.length = length; rectangle.width = width; Cuboid anotherCuboid = new Cuboid(); anotherCuboid.length = length; anotherCuboid.width = width; anotherCuboid.height = height; System.out.println("这是底面积计算:" + rectangle.calculateArea()); System.out.println("这是体积计算:" + anotherCuboid.calculateVolume()); } } ``` [2024-10-20 10:25:46 | AI写代码神器 | 319点数解答]