C#-—判断物体会不会下沉

/*烟台大学计算机学院学生      
*All right reserved.      
*文件名称:C#-—判断物体会不会下沉啊
*作者:杨飞      
*完成日期:2014年9月2日      
*版本号:v1.0      
*对任务及求解方法的描述部分:C#-—判断物体会不会下沉啊
*我的程序:*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{

    class PhysicalObject
    {
        private double weight;
        private double tiji;
        public PhysicalObject()
        {

        }
        public PhysicalObject(double weight, double tiji)
        {
            this.weight = weight;
            this.tiji = tiji;
           
        }
        public double midu()
        { 
        
            return (weight/tiji);
        }
        public void panduan()
        {
            if (midu() == 1)
            {
                Console.WriteLine("物体会悬浮");
            }
            if (midu() < 1)
            {
                Console.WriteLine("物体会上浮");

            }
            else
            {
                Console.WriteLine("物体会下沉");
            }
        
        }

    
    }
    class Program
    {
        static void Main(string[] args)
        {
            PhysicalObject s = new PhysicalObject(20, 15);
            s.midu();
            s.panduan();
            Console.ReadKey();
        }

    }
}


运行结果:C#-—判断物体会不会下沉_第1张图片

心得体会:呵呵

你可能感兴趣的:(C#-—判断物体会不会下沉)