
圆柱体的表面积和体积
//
// Copyright (c) 2014级软件1班
// All rithts reseved.
// 作者:A36 黄阿德
// 完成日期:2014年12月9日
//
// 问题描述:创建一个程序来求圆柱体的表面积和体积
// 输出:表面积和体积
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Cylinder coumn1 = new Cylinder();//创建对象
coumn1.height = 3.5;//引用类成员
coumn1.R = 3;//引用类成员
Console.WriteLine("体积:{0}", coumn1.Bulk());
Console.WriteLine("表面积:{0}", coumn1.Superficial());
Console.ReadKey();
}
}
class Cylinder
{
public double R;//定义函数R为圆柱体的圆的半径
public double height;//定义函数height圆柱体的高
public double Superficial()///定义函数Superficial
{
double lateral,S;//定义变量lateral:侧面积,S:圆底面积
double x=3.1415;//定义变量x:圆周率
lateral = (R + height) * 2;
S = x * Math.Pow(R, 2);
return lateral + S * 2;
}
public double Bulk()
{
double x = 3.1415;//定义变量S:圆底面积,x:圆周率
return x * Math.Pow(R, 2)*height;
}
}
}