//球体表面积A=4π*R^2,体积V=4/3π*R^3
Console.WriteLine("请输入圆的半径R");
double R=Convert.ToInt32(Console.ReadLine());
double round = 4 * Math.PI * R * R;
double volume = 4 * Math.PI * R * R * R / 3;
Console.WriteLine("圆的的表面积是{0};圆的体积是{1}",round,volume);
//圆锥表面积A=1/2*s*L+π*R^2,体积V=1/3*S*H=1/3π*R^2*H
Console.WriteLine("请输入圆锥的底面圆半径R");
double R1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入圆锥母线长s");
double s = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入圆锥的底面周长L");
double l = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入圆锥高H");
double H = Convert.ToInt32(Console.ReadLine());
double round1 = 0.5*s*l+Math.PI*R1*R1;
double volume1 = Math.PI*R1*R1*H/3;
Console.WriteLine("圆的的表面积是{0};圆的体积是{1}", round1, volume1);
//圆柱表面积A=L*H+2*S=2π*R*H+2π*R^2,体积V=S*H=π*R^2*H
//(L--底面周长,H--柱高,S--底面面积,R--底面圆半径)
Console.WriteLine("请输入H--柱高");
double H2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入R--底面圆半径");
double R2 = Convert.ToInt32(Console.ReadLine());
double A = 2 * Math.PI * R2 * H2 + 2 * Math.PI * R2 * R2;
double V = Math.PI * R2 * R2 * H2;
Console.WriteLine("圆柱表面积A{0},圆柱表面积V{1}",A,V);
Console.ReadKey();
#include #include using namespace std; #define PI 3.1415 class circle{public: void information(double & a) { cout>a; } }; class sphere:public circle{public: void first(double a) { double v1; double s1; s1=4*PI*a*a; //第一二处错误 v1=(PI*a*a*a*4)/3 ; cout>h; s2=2*2*PI*a*a+2*PI*a*h; v2=2*PI*a*a*h; cout>l; s2=2*PI*a*a+PI*a*l; v2=2*PI*a*a*l/3; cout>chose; circle bason; bason.information(a); cout<
using System;
namespace Cal
{
public class Program
{
private static double pi = 3.14;
static void Main()
{
do
{
double radius = 0, height = 0;
bool inputOK = false;
do
{
Console.Write("请输入圆柱体半径:");
string radiusStr = Console.ReadLine();
inputOK = double.TryParse(radiusStr, out radius);
if (inputOK)
{
Console.Write("请输入圆柱体高度:");
string heightStr = Console.ReadLine();
inputOK = double.TryParse(heightStr, out height);
}
}
while (!inputOK);
Console.WriteLine("圆柱体体积:" + GetCylinderVolume(radius, height));
Console.WriteLine("圆柱体面积:" + GetCylinderArea(radius, height));
Console.WriteLine("按回车键结束程序,按其他件继续进行计算。");
}
while (Console.ReadKey().KeyChar != 13);
}
private static double GetCylinderVolume(double radius, double height)
{
return pi * radius * radius * height;
}
private static double GetCylinderArea(double radius, double height)
{
return 2 * pi * radius * (height + radius);
}
}
}
class Cylinder{ private double radius; private double height; public double Radius { get { return radius; } set { radius = value; } } public double Height { get { return height; } set { height = value; } } public Cylinder(double r, double h) { radius = r; radius = h; } public double Volume() { return System.Math.Pi * radius * radius * height; } }
Main 函数里:
double r, h;Console.WriteLine("Input Radius: "); r = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Input Height: "); h = Convert.ToDouble(Console.ReadLine()); Cylinder cylinder = new Cylinder(r, h);Console.WriteLine(string.Format("Volume is {0}", cylinder.Volume()));Console.ReadLine();
const double pi=3.14;
public class dot
{}
public class circle:dot
{
#region 属性定义
private double _Radius=0.0;
#endregion
#region 访问器
public double Radius
{
get{return _Radius;}
set{this._Radius=value;}
}
#endregion
public double GetArea()
{
return this._Radius*pi;
}
}
哎呀我去..手码..累.. 如果你看得明白.其他的就是这么写. 如果不明白..就完蛋了..你要挂科..
用C#如何编写程序计算球,圆柱和圆锥的表面积和体积?_
: //球体表面积A=4π*R^2,体积V=4/3π*R^3 Console.WriteLine("请输入圆的半径R"); double R=Convert.ToInt32(Console.ReadLine()); double round = 4 * Math.PI * R * R; double volume = 4 * Math.PI * R * R * R / 3; Console.WriteLine("圆的的...
求帮忙写一道c#题目 :编写一个c#程序计算球、圆柱和圆锥的表面积和体积._
: #include using namespace std; #define PI 3.1415 class circle{public: void information(double & a) { cout>a; } }; class sphere:public circle{public: void first(double a) { double v1; double s1; s1=4*PI*a*a; //第一二处错误 v1=(PI*a*a*a*4)/3 ; cout>h; s2=...
使用c#虚函数编写程序求球体和圆柱体的体积及表面积_
: abstract class Circle { private double r; public double R { get {return r;} set{set r=value;} } public virtual double area(double r) { return 3.14*r*r; } public virtual double volume(double r) { return 0;//圆不能计算体积 } } class Sphere:Circle { public overwrite ...
C#【简答题】编写一个程序,分别计算正方体,球体和圆柱体的体积和表面积.要求使用多态性实现程序_
: 你的程序何止那几处错误,简直惨不忍睹.我简单的修改了,编译通过了.#include #include using namespace std;#define PI 3.1415class circle{public: void information(double & a) { cout>a; }};class sphere:public circle{public: void first(double a) ...
【用C#计算出球、圆柱和圆锥的表面积和体积的源代码:请帮我做哈】
: #include using namespace std;class Ccircle{protected: float r;public:};class Csphere:public Ccircle{private:public: Csphere(float R){r=R;} float getArea(){return 4*3.1416*r*r;} fl...
c#编写一个程序,输入一个球的半径(double 类型),然后调用spherVolum()方法并显示球的面积.谢谢!
: public double spherVolum(double r){double π= 3.14; return π * r * r; } 然后直接调用:Label1.Text = spherVolum(球的半径).ToString();
怎样用c#编写一个计算器程序
: 你是要做一个类似于Windows附带的计算器的还是直接输入表达式进行计算的? 第一种简单,无非就是做一些按钮并执行制定操作而已. 第二种我写了两份,分别使用正则表达式和语法分析技术 使用正则表达式的: using System; using ...
C#两个很简单的编程问题一球从100米高度自由落下_
: static double fun(int num) { double high = 100.0;//初始高度 for (int i = 0; i < num; i++) { high = high / 2; } return high; } static void Main(string[] args) {double H; H = fun(10); Console.WriteLine("当前高度: " + H); }
c 语言 编写一个计算球体体积的程序_
: printf("%f",v=4.0/3*PI*r*r*r); 如果写成4/3会按照整形运算,结果下去整 4/3=1;
用C# 控制台应用程序 编程: 创建一个类MyMath,输入半径,计算圆的周长、面积及球的体积.
: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class MyMath { static void Main(string[] args) { double pi = 3.14; string num=Console.ReadLine(); double r = System.Convert....