Example #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();
        }
Example #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();
        }
Example #3
0
 public static double area(box x)
 {
     return(2 * (x.high * x.width + x.width * x.depth + x.high * x.depth));
 }
Example #4
0
 public static double volume(box x)
 {
     return(x.high * x.width * x.depth);
 }