Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need book solution for the following- NEEDS TO BE WRITTEN IN C# Scenario: Write

ID: 3585027 • Letter: N

Question

Need book solution for the following-

NEEDS TO BE WRITTEN IN C#

Scenario: Write a console program that uses a Circle class to calculate a circle’s area, diameter and circumference given the circle’s radius. Fields (Property): • The circle’s Radius: a double, read and write

Constant: • PI: Constant value of 3.14159 Methods: -

Constructor: Accepts the radious of the circle class as an argument.

-Constructor: A no argument constructor that sets the radius to 0.

-GerArea: Returns the area of the circle, which is calculated as: Area = PI * radius * radius

-GetDiameter: Returns the circumference of the circle, which is calculated as: Circumference = 2 * PI * radius

Write a C# program that demonstrates the Circle class by asking the user for the circle’s radius, creating a circle object, and then reporting the circle’s area, diameter and circumference.

Explanation / Answer

//Please see the code below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication4
{
    class Circle
    {
        double radius;
        double PI = 3.14159;

        //Constructor: Accepts the radious of the circle class as an argument.
        Circle(double radius)
        {
            this.radius = radius;
        }

        //Constructor: A no argument constructor that sets the radius to 0
        Circle()
        {
            radius = 0.0;
        }

        //GerArea: Returns the area of the circle, which is calculated as: Area = PI * radius * radius
        double GerArea()
        {
            return PI * radius * radius;
        }
        /*GetDiameter: Returns the circumference of the circle, which is calculated as:
         *Circumference = 2 * PI * radius*/
        double getDiameter()
        {
            return 2 * PI * radius;
        }

        static void Main(string[] args)
        {

            Console.WriteLine("Please Enter the radius of the circle: ");
            double radius = double.Parse(Console.ReadLine());
            Circle c1 = new Circle(radius);
            Console.WriteLine("The Area of the circle is: "+c1.GerArea());
            Console.WriteLine("The Circumference of the circle is: " + c1.getDiameter());
            Console.ReadLine();

        }
    }
}

OUTPUT:

Please Enter the radius of the circle:
4
The Area of the circle is: 50.26544
The Circumference of the circle is: 25.13272

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote