static decimal pi = 3.14159M;
static private decimal VCON(decimal r, decimal h)
return (1M / 3M) * pi * r * r * h;
static private decimal VSPH(decimal r)
return (4M / 3M) * pi * r * r * r;
static private decimal VCYL(decimal r, decimal h)
static private decimal SACone(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 SACylinder(decimal r, decimal h)
static private decimal SASphere(decimal r)
public static void Main()
string choice = "ParseyParse";
while (choice != "Q" && choice != "q")
Console.WriteLine("Please input to find the surface area and volume of one of the following: 1 for cone, 2 for cylinder, 3 for sphere.");
ulong inp = ulong.Parse(Console.ReadLine());
Console.WriteLine("Please enter the value of the radius.");
decimal r = decimal.Parse(Console.ReadLine());
Console.WriteLine("Please enter the value of the height.");
decimal h = decimal.Parse(Console.ReadLine());
Console.WriteLine("The surface area of the cone: " + SACone(r,h).ToString("##.##"));
Console.WriteLine("The volume of the cone: " + VCON(r,h).ToString("##.##"));
Console.WriteLine("Please enter the value of the radius.");
decimal r = decimal.Parse(Console.ReadLine());
Console.WriteLine("Please enter the value of the height.");
decimal h = decimal.Parse(Console.ReadLine());
Console.WriteLine("The surface area of the cylinder: " + SACylinder(r,h).ToString("##.##"));
Console.WriteLine("The volume of the cylinder: " + VCYL(r,h).ToString("##.##"));
Console.WriteLine("Please enter the value of the radius.");
decimal r = decimal.Parse(Console.ReadLine());
Console.WriteLine("The surface area of the sphere: " + SASphere(r).ToString("##.##"));
Console.WriteLine("The volume of the sphere: " + VSPH(r).ToString("##.##"));
Console.WriteLine("Please enter one of the choices.");
Console.WriteLine("Please enter q to quit and any other key to continue");
choice = Console.ReadLine();