示例#1
0
        static void Main(string[] args)
        {
            box firstBox = new box();

            firstBox.length = double.Parse(Console.ReadLine());
            firstBox.width  = double.Parse(Console.ReadLine());
            firstBox.height = double.Parse(Console.ReadLine());

            Console.WriteLine("Box的面积是{0}", firstBox.area());
            Console.WriteLine("Box的体积是{0}", firstBox.volume());
            Console.ReadLine();
        }
示例#2
0
        static void Main(string[] args)
        {
            box cuboid = new box();

            Console.WriteLine("Input high ,width ,depth");
            cuboid.high  = Convert.ToDouble(Console.ReadLine());
            cuboid.width = Convert.ToDouble(Console.ReadLine());
            cuboid.depth = Convert.ToDouble(Console.ReadLine());
            Console.Write("volume=");
            Console.Write(box.volume(cuboid));
            Console.WriteLine();
            Console.Write("area=");
            Console.Write(box.area(cuboid));
            Console.ReadLine();
        }
示例#3
0
 public static double area(box x)
 {
     return(2 * (x.high * x.width + x.width * x.depth + x.high * x.depth));
 }
示例#4
0
 public static double volume(box x)
 {
     return(x.high * x.width * x.depth);
 }