早教吧作业答案频道 -->其他-->
C#练习题.请用C#设计一个长方体类CUB,该类能够计算并输出长方体的体积和表面积,要求(内附)请用C#设计一个长方体类CUB,该类能够计算并输出长方体的体积和表面积,要求(内附),要求(a)
题目详情
C#练习题.请用C#设计一个长方体类CUB,该类能够计算并输出长方体的体积和表面积,要求(内附)
请用C#设计一个长方体类CUB,该类能够计算并输出长方体的体积和表面积,要求(内附),
要求
(a)cub 类含长方体的长long宽width高height三个成员,并包含两个成员保存长方体的体积v和表面积S
(B)编写构造函数,为long和height及width赋初值
(c)并编写成员函数calcvolumn()和calcarea()计算长方体的体积和表面积
(D)编写成员函数print()输出V和s
(e)在program类中编写相应的Main()函数,生成长方体对象,输出对应的s和v
请用C#设计一个长方体类CUB,该类能够计算并输出长方体的体积和表面积,要求(内附),
要求
(a)cub 类含长方体的长long宽width高height三个成员,并包含两个成员保存长方体的体积v和表面积S
(B)编写构造函数,为long和height及width赋初值
(c)并编写成员函数calcvolumn()和calcarea()计算长方体的体积和表面积
(D)编写成员函数print()输出V和s
(e)在program类中编写相应的Main()函数,生成长方体对象,输出对应的s和v
▼优质解答
答案和解析
class Program
{
static void Main(string[] args)
{
Cub cube = new Cub(3, 4, 5);
cube.CalcArea();
cube.CalcVolume();
cube.Print();
Console.ReadLine();
}
}
class Cub
{
public int Length { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public int Volume { get; set; }
public int SuperficialArea { get; set; }
public Cub(int length, int width, int height)
{
this.Length = length;
this.Width = width;
this.Height = height;
}
public void CalcVolume()
{
Volume = Length * Width * Height;
}
public void CalcArea()
{
SuperficialArea = 2 * (Length * Width + Width * Height + Length * Height);
}
public void Print()
{
Console.WriteLine("表面积为:{0},体积为:{1}", SuperficialArea, Volume);
}
}
{
static void Main(string[] args)
{
Cub cube = new Cub(3, 4, 5);
cube.CalcArea();
cube.CalcVolume();
cube.Print();
Console.ReadLine();
}
}
class Cub
{
public int Length { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public int Volume { get; set; }
public int SuperficialArea { get; set; }
public Cub(int length, int width, int height)
{
this.Length = length;
this.Width = width;
this.Height = height;
}
public void CalcVolume()
{
Volume = Length * Width * Height;
}
public void CalcArea()
{
SuperficialArea = 2 * (Length * Width + Width * Height + Length * Height);
}
public void Print()
{
Console.WriteLine("表面积为:{0},体积为:{1}", SuperficialArea, Volume);
}
}
大小写什么的,名字什么的你自己看着改改就行了
看了 C#练习题.请用C#设计一个...的网友还看了以下:
数学问题(附算式或假设法或画图)有100个桃子,要分给5只大猴子和10只小猴子,你认为应该怎样分合 2020-04-26 …
()编写财务单项总结报告,财务报告后附财务报表,与初设概算对照表、概算调整表、合同支付情况表等。 2020-05-26 …
设计师为一种新上市的商品设计了长是5.5厘米,宽是3.5厘米,高是0.9厘米的长方体包装盒,厂家生 2020-06-04 …
列算是并解答电工班架设一条输电线路,上午架设了全长的百分之二十一,下午架设了全长的百分之三十六,下 2020-06-25 …
混凝土灌注设计桩长24米孔底标高-20.156护筒标高9.124怎么计算它打多深混凝土,留多少不灌 2020-06-29 …
假设设计桩长20米,浮浆0.5米,计算桩的混凝土是按20米算还是20.5米算? 2020-06-29 …
水中护筒埋设计算我们项目部下来个新活,要施工水中灌注桩,需要埋设钢护筒.河道水深为2.5m,淤泥深 2020-06-29 …
EXCEL如何计算负增长比例我将要求描述下吧:假设A增长数量为50,B增长数量为30,则A增长比例为 2020-11-01 …
英语翻译台缙高速公路全长126公里,采用四车道高速公路标准建设,计算行车速度为100公里/小时,整体 2020-12-15 …
在一张长8厘米的长方形的纸的一边,剪去一个最大的正方形,剩下的纸的周长是多少厘米?计算过程?(烦请附 2020-12-31 …