求矩形的周长和面积
Console.WriteLine("请输入矩形的宽度");
double width = double.Parse(Console.ReadLine());
Console.WriteLine("请输入矩形的高度");
double height = double.Parse(Console.ReadLine());
double area = width * height;
double length = 2 * (width + height);
Console.WriteLine("矩形的面积为" + area);
Console.WriteLine("矩形的周长为" + length);
Console.ReadLine();
求圆的面积周长案例
Console.WriteLine("请输入圆的半径");
double r = double. Parse(Console.ReadLine());
double area = Math.PI * r * r;
double length = 2* Math.PI * r;
//浮点类型的数据.ToString("f2") 保留两位小数
Console.WriteLine("圆的面积为" + area.ToString("f2"));
Conso