zoukankan      html  css  js  c++  java
  • 设计一个圆柱体类,计算表面积及体积。建立一个半径为3、高为3.5的圆柱体,输出其表面积及体积

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 
     7 namespace ConsoleApplication10
     8 {
     9     class Program
    10     {
    11         static void Main(string[] args)
    12         {
    13             double radius = 3;
    14             double high = 3.5;
    15             double superficial;
    16             double vol = volume(radius,high,out superficial);
    17             Console.WriteLine("表面积为:{0},体积为{1}",superficial,vol);
    18             Console.ReadKey();
    19         }
    20         static double volume(double radius, double high,out double superficial )//计算面积与体积的方法
    21         {
    22             double area = 3.14 * radius * radius;//圆的面积公式S=πr²
    23             double lateral = 2 * 3.14 * radius * high;//圆柱体侧面积=底面圆周长×高=2×3.14×底面半径×高
    24             superficial = lateral + (area * 2);//侧面积+底面积乘以2
    25             double volume = area * high;//体积
    26             return volume;
    27         }
    28     }
    29 }
  • 相关阅读:
    安装IIS
    安装Asp.Net(4.0.30319)
    转载一个博文
    文件操作引出流(二)FileStream和
    《学习之道》第十一章目前此章最后一点-重复
    《学习之道》第十一章意群
    Views
    Django的基本使用
    MVC框架
    Zookeeper
  • 原文地址:https://www.cnblogs.com/start-from-scratch/p/5065903.html
Copyright © 2011-2022 走看看