Write the C# statements to add the static method Area to your Circle class. It s
ID: 3635174 • Letter: W
Question
Write the C# statements to add the static method Area to your Circle class. It should return a float and accept a parameter radius of type float. The area of a circle is Pi * r * r. In C# Pi can be accessed as Math.PI and is of type double.
(Note: Do not re-type the class declaration, just provide the requested method.)
then write the C# statements to add the non-static method Area to your Circle class. It should return a float but not accept any arguments. This new Area method should not re-implement the equation for the area of a circle. Instead, you should invoke the static Area method you wrote in the previous statement.
now write 3 C# statements which test your Circle class.
The first statement should instantiate a Circle object with radius 5.
The second statement should output the newly instantiated circle's radius and area.
The third statement should output the area of a circle with a radius of 10 using the static Area method.
Explanation / Answer
static float Area(flaot r)
{
return Math.PI*r*r;
}
float Area()
{
return Area(r);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.