Exercise
Sphere, float
Objetive
Calculate the surface area and volume of a sphere, given its radius (surface area = 4 * pi * radius squared; volume = 4/3 * pi * radius cubed).
Note: For floating-point numbers, you should use Convert.ToSingle(...)
Example Code
using System;
public class exercise59
{
public static void Main()
{
float radius;
float pi = 3.1415926535f;
Console.Write("Radius? ");
radius = Convert.ToSingle(Console.ReadLine());
Console.WriteLine(4 * pi * (radius * radius));
Console.WriteLine(4 / 3 * pi * (radius * radius * radius));
}
}