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 VofCyl(decimal r, decimal h)
static private decimal VofSph(decimal r)
return (4M / 3M) * pi * r * r * r;
public static void Main()
Console.WriteLine("Would you like to calculate the volume and surface area of a cone, a cylinder, or a sphere?");
Console.WriteLine("Press 1 for the volume and surface area of a cone.");
Console.WriteLine("Press 2 for the volume and surface area of a cylinder.");
Console.WriteLine("Press 3 for the volume and surface area of a sphere.");
decimal choice = decimal.Parse(Console.ReadLine());
Console.WriteLine("What is the radius of your cone?");
decimal input1 = decimal.Parse(Console.ReadLine());
Console.WriteLine("What is the height of your cone?");
decimal input2 = decimal.Parse(Console.ReadLine());
Console.WriteLine("The volume of your cone is: " + VofCone(input1, input2).ToString("##.##"));
Console.WriteLine("The surface area of your cone is: " + SACone(input1, input2).ToString("##.##"));
Console.WriteLine("What is the radius of your cylinder?");
decimal input3 = decimal.Parse(Console.ReadLine());
Console.WriteLine("What is the height of your cylinder?");
decimal input4 = decimal.Parse(Console.ReadLine());
Console.WriteLine("The volume of your cylinder is: " + VofCyl(input3, input4).ToString("##.##"));
Console.WriteLine("The surface area of your cylinder is: " + SACyl(input3, input4).ToString("##.##"));
Console.WriteLine("What is the radius of your sphere?");
decimal input5 = decimal.Parse(Console.ReadLine());
Console.WriteLine("The volume of your sphere is " + VofSph(input5).ToString("##.##"));
Console.WriteLine("The surface area of your sphere is: " + SASphere(input5).ToString("##.##"));
Console.WriteLine("You have entered an invalid number. Please enter a valid number.");
Console.WriteLine("Press q to quit or any other key to continue.");
restart = Console.ReadLine();