public static void Main()
Console.WriteLine("Area of various geometrical shapes");
Console.WriteLine("----------------------------------");
Console.WriteLine("Select an option:");
Console.WriteLine("[1]Area of a Circle");
Console.WriteLine("[2]Area of a Rectangle");
Console.WriteLine("[3]Area of a Triangle");
Console.Write("Enter your option:");
choice = Console.ReadLine();
if (Int32.TryParse(choice, out choiceResult) == true) {
if (choiceResult > 3 | choiceResult < 1) {
Console.WriteLine("Input error. Please select from 1 - 3 only.");
Console.Write("Enter radius of the circle: ");
radius = Console.ReadLine();
if (double.TryParse(radius, out radiusResult) == true) {
Console.WriteLine("Input error. Zero or negative value of radius is not allowed.");
area = (radiusResult * radiusResult) * 3.1416;
Console.WriteLine("The area of the circle is {0:#,0.0000}.", area);
Console.WriteLine("Invalid radius. Please input a valid value of radius.");
else if (choiceResult == 2) {
Console.Write("Enter the length of the rectangle: ");
length = Console.ReadLine();
Console.Write("Enter the width of the rectangle: ");
width = Console.ReadLine();
if (double.TryParse(length, out lengthResult) == true & double.TryParse(width, out widthResult) == true) {
if (lengthResult <= 0 & widthResult <= 0) {
Console.WriteLine("Input errors. Zero or negative value of length and width is not allowed.");
else if (lengthResult <= 0) {
Console.WriteLine("Input error. Zero or negative value of length is not allowed.");
else if (widthResult <= 0) {
Console.WriteLine("Input error. Zero or negative value of width is not allowed.");
area = widthResult * lengthResult;
Console.WriteLine("The area of the rectangle is {0:#,0.0000}.", area);
} else if (double.TryParse(length, out lengthResult) == false | double.TryParse(width, out widthResult) == false) {
if (double.TryParse(length, out lengthResult) == false & double.TryParse(width, out widthResult) == false) {
Console.WriteLine("Invalid length and width. Please input a valid value of length and width.");
else if (double.TryParse(width, out widthResult) == false & lengthResult > 0) {
Console.WriteLine("Invalid width. Please input a valid value of width.");
else if (double.TryParse(length, out lengthResult) == false & widthResult > 0) {
Console.WriteLine("Invalid length. Please input a valid value of length.");
else if (double.TryParse(length, out lengthResult) == false & widthResult <= 0) {
Console.WriteLine("Invalid length option and invalid width input. Please input a valid value of length. Zero or negative value of width is not allowed.");
else if (double.TryParse(width, out widthResult) == false & lengthResult <= 0) {
Console.WriteLine("Invalid width option and invalid length input. Please input a valid value of width. Zero or negative value of length is not allowed.");
else if (choiceResult == 3) {
Console.Write("Enter the base of the triangle: ");
Base = Console.ReadLine();
Console.Write("Enter the height of the triangle: ");
height = Console.ReadLine();
if (double.TryParse(Base, out BaseResult) == true & double.TryParse(height, out heightResult) == true) {
if (BaseResult <= 0 & heightResult <= 0) {
Console.WriteLine("Input errors. Zero or negative value of base and height is not allowed.");
else if (BaseResult <= 0) {
Console.WriteLine("Input error. Zero or negative value of base is not allowed.");
else if (heightResult <= 0) {
Console.WriteLine("Input error. Zero or negative value of height is not allowed.");
area = (heightResult * BaseResult) / 2;
Console.WriteLine("The area of the triangle is {0:#,0.0000}.", area);
} else if (double.TryParse(height, out heightResult) == false | double.TryParse(Base, out BaseResult) == false) {
if (double.TryParse(height, out heightResult) == false & double.TryParse(Base, out BaseResult) == false) {
Console.WriteLine("Invalid height and base. Please input a valid value of height and base.");
else if (double.TryParse(height, out heightResult) == false & BaseResult > 0) {
Console.WriteLine("Invalid height. Please input a valid value of height.");
else if (double.TryParse(Base, out BaseResult) == false & heightResult > 0) {
Console.WriteLine("Invalid base. Please input a valid value of base.");
else if (double.TryParse(Base, out BaseResult) == false & heightResult <= 0) {
Console.WriteLine("Invalid base option and invalid height input. Please input a valid value of base. Zero or negative value of height is not allowed.");
else if (double.TryParse(height, out heightResult) == false & BaseResult <= 0) {
Console.WriteLine("Invalid height and invalid base input. Please input a valid value of height. Zero or negative value of base is not allowed.");
if (Int32.TryParse(choice, out choiceResult) == false) {
Console.WriteLine("Invalid option. Please select from 1 - 3 only.");