Answer to Question #250923 in C# for Plea

Question #250923

Design wrapper classes about the surface area of a rectangle


1
Expert's answer
2021-10-13T16:58:37-0400
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();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS