public class Test2 {
public static void main(String[] args) {
double r = 2;
double h = 5;
double volume = Cylinder.cubage(r, h);
System.out.println("Volumen is: " + volume);
}
}
class Circle {//圆
private double r;
public Circle(double radius) {
this.r = radius;
}
public double area() {
return Math.PI * Math.pow(r, 2);
}
}
class Cylinder {//圆柱体
public static double cubage(double r, double h) {//求体积
Circle baseCircle = new Circle(r);//底面圆
return baseCircle.area() * h;
}
}
时双崽崽!
public class area
{
private:
float r;
public:
float s( r);
}
public float area:s(r)
{
float s;
s=3.1415926*r*r;
return s;
}
main()
{
float v;
float h;
scanf("%f,%f",h,r);
area carea;
v=carea::s(r)*h;
printf("%f",v);
}