Design wrapper classes about the surface area of a rectangle
using System;
namespace App
{
class Rectangle
{
private double width;
private double height;
public Rectangle() { }
public Rectangle(double width, double height) {
this.width = width;
this.height = height;
}
public double CalculateSurface()
{
return height * width;
}
}
class Program
{
static void Main(string[] args)
{
Console.Write("Enter the width of the rectangle: ");
double width = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the height of the rectangle: ");
double height = Convert.ToDouble(Console.ReadLine());
Rectangle rectangle = new Rectangle(width, height);
Console.WriteLine("The surface area of a rectangle = {0}", rectangle.CalculateSurface());
Console.ReadLine();
}
}
}
Comments
Leave a comment