
public class TruncatedCone {
    private double baseRadius;
    private double topRadius;
    private double height;
    
    public TruncatedCone(double bR, double tR, double h) {
        baseRadius = bR;
        topRadius = tR;
        height = h;
    }
    
    public double slantHeight() {
        return Math.sqrt((baseRadius - topRadius) * (baseRadius - topRadius) + height * height);
    }
    
    public double volume() {
        return height * Math.PI / 3.0 * (Math.pow(baseRadius, 2) 
                + (baseRadius * topRadius) + Math.pow(topRadius, 2));
    }
    
    public double lateralArea() {
        return (baseRadius + topRadius) * Math.PI * slantHeight();
    }
    
    public double surface() {
        return Math.PI * Math.pow(baseRadius, 2)
               + Math.PI * Math.pow(topRadius, 2)
               + lateralArea();
    }
    
    public static void main(String[] args) {
        if (args.length != 3) {
            System.out.println("Usage: java TruncatedCone R r h");
            return;
        }
        // kann auch Kegelstümpfe mit Kommazahlen berechnen.
        double bR = Double.parseDouble(args[0]);
        double tR = Double.parseDouble(args[1]);
        double h = Double.parseDouble(args[2]);
        TruncatedCone cone = new TruncatedCone(bR, tR, h);
        System.out.print(cone.volume());
        System.out.print(";");
        System.out.print(cone.surface());
        System.out.print(";");
        System.out.print(cone.lateralArea());
        System.out.print(";");
        System.out.println(cone.slantHeight());
    }

}
