using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
public class Rectangle
{
double length;
double width;
public Rectangle(double length, double width)
{
this.length = length;
this.width = width;
}
public double getarea()
{
return length * width;
}
}
public class Cuboid : Rectangle
{
private double h;
public Cuboid(double length, double width,double h):base(length,width)
{
this.h = h;
}
public double getvolume()
{
return getarea()*h;
}
}
class Program
{
static void Main(string[] args)
{
double length = double.Parse(Console.ReadLine());
double width = double.Parse(Console.ReadLine());
double h = double.Parse(Console.ReadLine());
Cuboid cuboid = new Cuboid(length,width,h);
Console.WriteLine("矩形面积为:"+cuboid.getarea());
Console.WriteLine("长方体体积为:" + cuboid.getvolume());
Console.Read();
}
}
}
04-22
4869
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-20
08-25
3769
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-23
4419
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交