体积算不出来

来源:6-8 最终项目

慕UI1157668

2017-01-11 16:17

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

namespace ConsoleApplication2
{
    class LaoChi
    {
        class LaoChiV
        {
            double V;                     //蓄水容积
            double H1, S1, S2;      //有效水深、池口水面面积、池底水面面积
            double H2, R1, R2;      //有效水深、池口半径、池底半径
            double H3, Ru;            //有效水深、圆半径
            double H4, R, r;          //有效水深、椭圆长的半径、椭圆短的半径
            public double JuXingLC()
            {
                Console.WriteLine("请分别输入有效水深、池口的水面面积、池底的水面面积:");
                H1 = double.Parse(Console.ReadLine());
                S1 = double.Parse(Console.ReadLine());
                S2 = double.Parse(Console.ReadLine());
                Console.WriteLine("矩形涝池蓄水容积V: {0} ",V=1 / 2 * H1 * (S1 + S2));
                return V;
            }
            public double PdyuanxingLC()
            {
                Console.WriteLine("请分别输入有效水深、池口半径、池底的半径:");
                H2 = double.Parse(Console.ReadLine());
                R1 = double.Parse(Console.ReadLine());
                R2 = double.Parse(Console.ReadLine());
                Console.WriteLine("平底圆形涝池蓄水容积V: {0} ", V = 3.14 / 2 * (R1 + R2) * H2);
                return V;
            }
            public double UzixingLC()
            {
                Console.WriteLine("请分别输入有效水深、圆的半径:");
                H3 = double.Parse(Console.ReadLine());
                Ru = double.Parse(Console.ReadLine());
                Console.WriteLine("‘U’字形涝池蓄水容积V: {0} ", V = 3 / 5 * 3.14 * Ru * H3);
                return V;
            }
            public double TuoyuanxingLC()
            {
                Console.WriteLine("请分别输入有效水深、椭圆长的半径、椭圆短的半径:");
                H4 = double.Parse(Console.ReadLine());
                R = double.Parse(Console.ReadLine());
                r = double.Parse(Console.ReadLine());
                Console.WriteLine("椭圆形涝池蓄水容积V: {0} ", V = 2 / 3 * 3.14 * (R - r) * H4);
                return V;
            }
            static void Main(string[] args)
            {
                LaoChiV lv = new LaoChiV();
                lv.JuXingLC();
                lv.PdyuanxingLC();
                lv.UzixingLC();
                lv.TuoyuanxingLC();
            }
        }
    }
}


写回答 关注

1回答

  • 慕粉2110335755
    2017-01-11 22:22:20
    已采纳


    你将计算公式的第一个数字变成浮点型就可以了,Console.WriteLine("矩形涝池蓄水容积V:{0}", V = 1.0 / 2 * H1 * (S1 + S2)

    慕UI115...

    懂了,谢谢!

    2017-01-12 23:20:58

    共 1 条回复 >

C#开发轻松入门

本门课程是C#语言的入门教程,将带你轻松入门.NET开发

254118 学习 · 1459 问题

查看课程

相似问题