public class GeometricalShape
public static void Main()
Console.WriteLine("Area of various geometrical shape");
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Select an option.");
Console.WriteLine("[1] Area of Circle");
Console.WriteLine("[2] Area of Rectangle");
Console.WriteLine("[3] Area of Triangle ");
Console.Write("Enter your option: ");
optionInput = Console.ReadLine();
if(Int32.TryParse(optionInput, out optionInt) == true)
Console.Write("Enter radius of circle: ");
circleInput = Console.ReadLine();
if (double.TryParse(circleInput, out circleInt) == true)
circleRadius = 3.1416*circleInt*circleInt;
Console.WriteLine("The area of the circle is {0:#,0.0000}", circleRadius);
Console.WriteLine("Input error. Zero or negative value of radius is not allowed.");
Console.WriteLine("Invalid radius. Please input a valid value of radius.");
Console.Write("Enter length of the rectangle: ");
lengthInput = Console.ReadLine();
if (double.TryParse(lengthInput, out lengthInt) == true)
Console.Write("Enter width of the rectangle ");
widthInput = Console.ReadLine();
if (double.TryParse(widthInput, out widthInt) == true)
area = lengthInt*widthInt;
Console.WriteLine("The area of the rectangle is {0:#,0.0000}", area);
Console.WriteLine("Input error. Zero or negative value of width is not allowed.");
Console.WriteLine("Invalid width. Please input a valid value of width.");
Console.WriteLine("Input error. Zero or negative value of length is not allowed.");
Console.WriteLine("Invalid length. Please input a valid value of length.");
Console.Write("Enter the base of the triangle: ");
baseInput = Console.ReadLine();
if (double.TryParse(baseInput, out baseInt) == true)
Console.Write("Enter the height of the triangle: ");
heightInput = Console.ReadLine();
if (double.TryParse(heightInput, out heightInt) == true)
areaTriangle = baseInt * heightInt / 2;
Console.WriteLine("The area of the triangle is {0:#,0.0000}", areaTriangle);
Console.WriteLine("Input error. Zero or negative value of height is not allowed.");
Console.WriteLine("Invalid height. Please input a valid value of height.");
Console.WriteLine("Input error. Zero or negative value of base is not allowed.");
Console.WriteLine("Please input a valid Input.");
Console.WriteLine("Input error. Please select from 1-3 only.");
Console.WriteLine("Invalid option. Please select from 1-3 only.");