public static String restart = "123872131";
public static String MSG_LINE;
public static decimal pi = 3.14159M;
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 SASphere(decimal r)
static private decimal SACyl(decimal r, decimal h)
return 2M * pi * r2 + 2M * pi * r * h;
static private decimal VofCone(decimal r, decimal h)
return (1M / 3M) * pi * r * r * h;
static private decimal VofSphere(decimal r)
return (4M / 3M) * pi * r * r * r;
static private decimal VofCylinder(decimal r, decimal h)
public static void Main()
while (restart != "q" || restart != "Q")
Console.WriteLine(MSG_LINE);
Console.WriteLine("Press a to calcuate the volume of a cone");
Console.WriteLine("Press b to calcuate the volume of a sphere");
Console.WriteLine("Press c to calcuate the volume of a cylinder");
String ans = Console.ReadLine();
Console.WriteLine("You've selected to calcuate the volume of a cone.");
Console.WriteLine("Please enter the radius of the cone");
decimal rcone = decimal.Parse(Console.ReadLine());
Console.WriteLine("Please enter the height of the cone");
decimal hcone = decimal.Parse(Console.ReadLine());
Console.WriteLine("The volume of your cone is, " + VofCone(rcone, hcone).ToString("##.##"));
Console.WriteLine("The surface area of your cone is, " + SACone(rcone, hcone).ToString("##.##"));
Console.WriteLine(MSG_LINE);
Console.WriteLine("Press q to quit, or any other key to continue the program");
restart = Console.ReadLine();
Console.WriteLine("You've selected to calcuate the volume of a sphere.");
Console.WriteLine("Please enter the radius of the sphere");
decimal rcone = decimal.Parse(Console.ReadLine());
Console.WriteLine("The volume of your sphere is, " + VofSphere(rcone).ToString("##.##"));
Console.WriteLine("The surface area of your cone is, " + SASphere(rcone).ToString("##.##"));
Console.WriteLine(MSG_LINE);
Console.WriteLine("Press q to quit, or any other key to continue the program");
restart = Console.ReadLine();
Console.WriteLine("You've selected to calcuate the volume of a cylinder.");
Console.WriteLine("Please enter the radius of the cylinder");
decimal rcylinder = decimal.Parse(Console.ReadLine());
Console.WriteLine("Please enter the height of the cylinder");
decimal hcylinder = decimal.Parse(Console.ReadLine());
Console.WriteLine("The volume of your cylinder is, " + VofCylinder(rcylinder, hcylinder).ToString("##.##"));
Console.WriteLine("The surface area of your cylinder is, " + SACyl(rcylinder, hcylinder).ToString("##.##"));
Console.WriteLine(MSG_LINE);
Console.WriteLine("Press q to quit, or any other key to continue the program");
restart = Console.ReadLine();
Console.WriteLine("Invalid user input. Please select a function");