早教吧作业答案频道 -->其他-->
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#设计一个...的网友还看了以下:
选出画线部分发音不同的单词.怎么写?A.student(u)B.cute(u)C.but(u)A. 2020-05-14 …
已知下图,U为全集,M、N是非空的两个集合,那么图中阴影部分的面积可表示( )已知下图,U为全集, 2020-05-16 …
椭圆方程式的题椭圆方程x^2/a^2+y^2/b^2=t怎么用y=f(u),x=f(u)表示如果椭 2020-05-16 …
求最大值cos(a)/u+sin(a)cos(a)/u+sin(a)a=?时有最大值?0尤其是构造 2020-06-03 …
关于探究细胞表面积与体积的关系的说法u错误的是()A.酚酞遇到NaOH呈现紫红色B.琼脂块越小,N 2020-06-21 …
若E表示电动势,U表示外电压,U′表示内电压,R表示外电路的总电阻,r表示内电阻,I表示电流,则下 2020-07-13 …
用字母表示下面的数量关系.(1)a表示工作效率,t表示工作时间,s表示工作总量.s=————,a= 2020-07-26 …
已知全集U={x|x∈N,x<10},A={x|x=2k,k∈N,x∈U},B={x|x2-3x+ 2020-08-01 …
如果用u表示速度,t表示时间,s表示路程,那么s=(),t=().用a表示正方形的边长,c表示周长, 2020-11-30 …
频率一定的声源在空气中向着静止的接收器匀速运动.以u表示声源的速度,v表示声波的速度(u<v),f表 2020-12-15 …