using System;
namespace ConsoleApp1
{
class Rectangle
{
double length;
double width;
public Rectangle(double h, double w)
{
this.length = h;
this.width = w;
}
public double getarea()
{
return length * width;
}
}
class Program
{
static void Main(string[] args)
{
double w, h;
w = Convert.ToDouble(Console.ReadLine());
h = Convert.ToDouble(Console.ReadLine());
Rectangle R = new Rectangle(w, h);
Console.WriteLine("矩形面积为{0}", R.getarea());
Console.ReadLine();
}
}
}
C#------设计控制台应用程序,计算矩形的面积。要求在程序中定义一个类,其中包含两个字段用于存储矩形的长和宽
最新推荐文章于 2024-07-13 10:45:00 发布