static decimal pi = 3.14159M;
static private decimal volofcone(decimal r, decimal h)
return (1M / 3M) * r * r * pi * h;
static private decimal volofcylinder(decimal r, decimal h)
static private decimal volofsphere(decimal r)
return (4M / 3M) * r * r * r * pi;
public static void Main()
Console.WriteLine("Press 1 to calculate the volume of a cone, 2 to calculate the volume of a cylinder, and 3 to calculate the volume of a sphere.");
string choice = Console.ReadLine();
Console.WriteLine("Please enter the radius of the cone.");
decimal radius = decimal.Parse(Console.ReadLine());
Console.WriteLine("Please enter the height of the cone.");
decimal height = decimal.Parse(Console.ReadLine());
Console.WriteLine("The volume of the cone is: " + volofcone(radius, height).ToString("##.##"));
Console.WriteLine("Please Enter the radius of the cylinder.");
decimal radius2 = decimal.Parse(Console.ReadLine());
Console.WriteLine("Please enter the height of the cylinder.");
decimal height2 = decimal.Parse(Console.ReadLine());
Console.WriteLine("The volume of the cylinder is: " + volofcylinder(radius2, height2).ToString("##.##"));
Console.WriteLine("Please Enter the radius of your sphere.");
decimal radius3 = decimal.Parse(Console.ReadLine());
Console.WriteLine("The volume of the sphere is: " + volofsphere(radius3).ToString("##.##"));
Console.WriteLine("Enter a valid option.");
Console.WriteLine("Press q to quit or anything else to continue.");
choice = Console.ReadLine();