Develop a c# windows application for the class circle and write test program to test the circle class.
using System;
using System.Collections.Generic;
namespace СircleApp
{
class Circle
{
private double radius;
public double Radius
{
get { return radius; }
set { radius = value; }
}
public Circle(double radius)
{
this.radius = radius;
}
public Circle()
{
radius = 0.0;
}
public double calculateArea()
{
return Math.PI *Math.Pow(radius,2);
}
public double calculateDiameter()
{
return radius * 2;
}
public double calculateCircumference()
{
return 2 * Math.PI * radius;
}
}
class Program
{
static void Main(string[] args)
{
Circle circle = new Circle(5);
Console.WriteLine("The radius of the circle: {0} ", circle.Radius);
Console.WriteLine("The diameter of the circle: {0} ", circle.calculateDiameter());
Console.WriteLine("The circumference of the circle: {0} ", circle.calculateCircumference());
Console.WriteLine("The area of the circle: {0} ", circle.calculateArea());
Console.ReadLine();
}
}
}
Comments
Leave a comment