Ejercicio
Esfera, float
Objetivo
Calcular la superficie y el volumen de una esfera, dado su radio (superficie = 4 * pi * radio al cuadrado; volumen = 4/3 * pi * radio al cubo).
Sugerencia: para números "flotantes", debe usar Convert.ToSingle (...)
Código de Ejemplo
using System;
class Program
{
static void Main()
{
Console.Write("Enter the radius of the sphere: ");
float radius = Convert.ToSingle(Console.ReadLine());
float surfaceArea = 4 * (float)Math.PI * (radius * radius);
float volume = (4f / 3f) * (float)Math.PI * (radius * radius * radius);
Console.WriteLine($"Surface Area of the sphere: {surfaceArea:F2} square units");
Console.WriteLine($"Volume of the sphere: {volume:F2} cubic units");
}
}