You are on page 1of 2

Activity # 7 – Methods and Constructors

1. Debug the program

internal class Program


{

public string color;

public Program(double r, string c)


{
radius=5;

public void getRadius()


{

Console.WriteLine("Radius: " + radius);


}
public void getColor()
{

Console.WriteLine("Color: " + color);


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

static void Main(string[] args)


{
Program circle = new Program();
circle1.getColor();
circle1.getRadius();
Console.WriteLine("Area: " + circle1.getArea());
Console.ReadKey();
}
}

2. Modify the program you have debugged to add the following:


A. Create an overloaded getRadius() that will accept an integer.
B. Use the overloaded getRadius().
C. Create a method getCircumference to calculate the circumference of
the circle. Formula: 2 * Math.PI * radius;
D. Output the circumference of the circle.

You might also like