Answer to Question #235949 in C# for AhsanAzam

Question #235949

Develop a c# windows application for the class circle and write test program to test the circle class.


1
Expert's answer
2021-09-11T14:25:29-0400




using System;
using System.Collections.Generic;
namespace СircleApp
{
    class Circle
    {


        private double radius;               // Radius of the circle




        /**
         * Constructor
         *
         * @param radius The circles radius
         */


        public Circle(double radius)
        {
            this.radius = radius;
        }


        /**
         * Constructor No arg constructor that the sets the radius field to 0.0
         */


        public Circle()
        {
            radius = 0.0;
        }


        /**
         * The setRadius method sets the Circles radius
         * @param radius returns radius of the circle
         */


        public void setRadius(double radius)
        {
            this.radius = radius;
        }


        /**
         * The getRadius method
         * @return the radius of the circle
         */


        public double getRadius()
        {
            return radius;
        }


        /**
         * The getArea method
         * @return the area of the circle
         */


        public double getArea()
        {
            return Math.PI * radius * radius;
        }


        /**
         * The getDiameter method
         * @return the diameter of the circle
         */


        public double getDiameter()
        {
            return radius * 2;
        }


        /**
         * The getCircumference method
         * @return the circumference of the circle
         */


        public double getCircumference()
        {
            return 2 * Math.PI * radius;
        }


    }






    class Program
    {
        static void Main(string[] args)
        {


            Circle circle = new Circle(10);


            Console.WriteLine("The radius of the circle: {0} ", circle.getRadius());
            Console.WriteLine("The diameter of the circle: {0} ", circle.getDiameter());
            Console.WriteLine("The circumference of the circle: {0} ", circle.getCircumference());
            Console.WriteLine("The area of the circle: {0} ", circle.getArea());


            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
New on Blog
APPROVED BY CLIENTS