{static decimal pi = 3.141592654M;
static private decimal vcone(decimal r, decimal h)
return (1M/3M) * pi * r * r * h;
static private decimal vcylinder(decimal r, decimal h)
static private decimal vsphere(decimal r)
return (4M/3M) * pi * r * r * r;
static private decimal scone(decimal r, decimal h)
double r2 = (double)r * (double)r;
double h2 = (double)h * (double)h;
double slant = Math.Sqrt(r2 + h2);
return pi * r * r + pi * r * (decimal)slant;
static private decimal ssphere(decimal r)
static private decimal scylinder(decimal r, decimal h)
return 2M * pi * r2 + 2M * pi * r * h;
public static void Main()
Console.WriteLine("Hello and Welcome to my Volume and Surface Area calculator, press 1 to calculate cone, 2 for cylinder and 3 for sphere.");
string menu = Console.ReadLine();
Console.WriteLine("Input the radius of the cone");
decimal r1 = decimal.Parse(Console.ReadLine());
Console.WriteLine("Input the height of the cone");
decimal h1 = decimal.Parse(Console.ReadLine());
Console.WriteLine("Your volume is " + vcone(r1,h1));
Console.WriteLine("Your surface area is " + scone(r1,h1));
Console.WriteLine("Input the radius of the cylinder");
decimal r2 = decimal.Parse(Console.ReadLine());
Console.WriteLine("Input the height of the cylinder");
decimal h2 = decimal.Parse(Console.ReadLine());
Console.WriteLine("Your volume is " + vcylinder(r2,h2));
Console.WriteLine("Your surface area is " + scylinder(r2,h2));
Console.WriteLine("Input the radius of the sphere");
decimal r3 = decimal.Parse(Console.ReadLine());
Console.WriteLine("Your volume is " + vsphere(r3));
Console.WriteLine("Your surface area is " + ssphere(r3));
Console.WriteLine("Error! Option not in menu, please try again");
Console.WriteLine("1 for calculating cone, 2 for cylinder and 3 for sphere");
Console.WriteLine("Press enter to restart and go back to the menu");