是一个很基本的题目
namespace cylinder
{
class Program
{
static void Main(string[] args)
{
Cylin myCylin = new Cylin();
myCylin.r = 2.5;
myCylin.h = 3.2;
Console.WriteLine("圆柱体的表面积为{0},体积为{1}", myCylin.Scylin(),myCylin.Vcylin());
}
}
class Cylin
{
const double pi = 3.1415926;
public double r;
public double h;
public Cylin()
{
}
public Cylin(double a, double b)
{
r = a;
h = b;
}
public double Scylin()
{
double s = 0;
s = 2 * pi * r * (r + h);
return s;
}
public double Vcylin()
{
double v = 0;
v = pi * r * r * h;
return v;
}
}
}