Practice: Methods
Fill in the missing blanks to create a method that calculates the area of a circle and returns the value.
index.cs
123456789101112131415161718192021222324252627282930313233using System; public class ConsoleApp { class Point { public double x; public double y; } class Circle { public double radius; public Point center; ___ ___ ___() { // The formula is: pi . r . r // The value of pi is 3.14 // r is the radius ___ ___ * ___* radius; } } public static void Main(string[] args) { Point p = new Point(); p.x = 15; p.y = 15; Circle circle = new Circle(); circle.radius = 10; circle.center = p; Console.WriteLine($"Area of the circle with center at ({circle.center.x}, {circle.center.y}) and radius of {circle.radius} is {circle.area()}"); } }
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 3. Capítulo 8
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Awesome!
Completion rate improved to 2.04
Practice: Methods
Desliza para mostrar el menú
Fill in the missing blanks to create a method that calculates the area of a circle and returns the value.
index.cs
123456789101112131415161718192021222324252627282930313233using System; public class ConsoleApp { class Point { public double x; public double y; } class Circle { public double radius; public Point center; ___ ___ ___() { // The formula is: pi . r . r // The value of pi is 3.14 // r is the radius ___ ___ * ___* radius; } } public static void Main(string[] args) { Point p = new Point(); p.x = 15; p.y = 15; Circle circle = new Circle(); circle.radius = 10; circle.center = p; Console.WriteLine($"Area of the circle with center at ({circle.center.x}, {circle.center.y}) and radius of {circle.radius} is {circle.area()}"); } }
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 3. Capítulo 8