Create a C# program that will have the user enter the height and radius of a cyl
ID: 3683068 • Letter: C
Question
Create a C# program that will have the user enter the height and radius of a cylinder. The program will provide a menu that will allow the user to choose to calculate the volume or the surface area. • You must create a method to read in a value which will be used to find the height and the radius. • You must create a method that will find the surface area of a cylinder. (Use Google or a math book to find the formula.) • You must create a method that will find the volume of a cylinder. (Use Google or a math book to find the formula.) • You must use a method to print out the answers. Sample Run: Choose the formula for a cylinder you would like to use by entering 1 or 2. 1 – Surface Area of a Cylinder 2 – Volume of a Cylinder 2 Enter the height of the cylinder: 8 Enter the radius of the cylinder; 4 The volume of the cylinder is ##.#.Explanation / Answer
Answer:
using System;
using System.IO;
class programofsphere
{
public static void Main()
{
int option;
double r, surface_area_of_sphere, volume_of_sphere;
double PI = 3.14;
do{
cout << "Enter 1 to display surface area and volume of cylinder: " << endl;
cout << "Enter 2 to Quit Program " << endl;
cin>>option;
if(option==1){
Console.WriteLine("Enter the Radius of the Sphere: ");
r = Convert.ToDouble(Console.ReadLine());
surface_area_of_sphere = 4* PI * r * r;
volume_of_sphere = (4.0 / 3) * PI * r * r * r;
Console.WriteLine("Surface Area of Sphere is : ", surface_area_of_sphere);
Console.WriteLine("Volume of Sphere is : ", volume_of_sphere);
Console.Read();}
else{
Console.WriteLine("Invalid Option Entered Please Check.Thank You");
}
}while(option!=2)
}
}