using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace GeometricCalculations { class Triangle { public double area; public double baseWidth; public double height; public void CalculateTriangleArea(string measurementType) { Console.WriteLine("What is the height of the triangle you are attempting to measure?"); height = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("What is the base of the triangle you are attempting to measure?"); baseWidth = Convert.ToDouble(Console.ReadLine()); area = 0.5 * (baseWidth * height); Console.WriteLine("The area of the triangle is " + area + " " + measurementType); Console.Write("Press Enter To TerminateÉ"); Console.Read(); } } class Square { public double area; public double side; public void CalculateSquareArea(string measurementType) { Console.WriteLine("What is the length of the square you are attempting to measure?"); side = Convert.ToDouble(Console.ReadLine()); area = (Math.Sqrt(side)); Console.WriteLine("The area of the circle is " + area + " " + measurementType); Console.Write("Press Enter To TerminateÉ"); Console.Read(); } } class Rectangle { public double area; public double width; public double height; public void CalculateRectangleArea(string measurementType) { Console.WriteLine("What is the width of the rectangle you are attempting to measure?"); height = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("What is the height of the triangle you are attempting to measure?"); baseWidth = Convert.ToDouble(Console.ReadLine()); area = width * height; Console.WriteLine("The area of the triangle is " + area + " " + measurementType); Console.Write("Press Enter To TerminateÉ"); Console.Read(); } } class Parallelogram { public double area; public double baseWidth; public double verticalHeight; public void CalculatePareallelogramArea(string measurementType) { Console.WriteLine("What is the base of the parallelogram you wish to measure?"); baseWidth = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("What is the height of the parallelogram you are attempting to measure?"); baseWidth = Convert.ToDouble(Console.ReadLine()); area = baseWidth * verticalHeight; Console.WriteLine("The area of the parallelogram is " + area + " " + measurementType); Console.Write("Press Enter To TerminateÉ"); Console.Read(); } } class Trapezod { public double area; public double topWidth; public double bottomWidth; public double verticalHorizon; public void CalculateTrapezoidArea(string measurementType) { Console.WriteLine("What is the width of the top of the trapezoid you are attempting to measure?"); topWidth = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("What is the width of the bottom of the trapezoid you are attempting to measure?"); bottomWidth = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("What is the vertical horizon of the trapezoid you are attempting to measure?"); verticalHorizon = Convert.ToDouble(Console.ReadLine()); area = 0.5 * (topWidth + bottomWidth) * verticalHorizon; Console.WriteLine("The area of the trapezoid is " + area + " " + measurementType); Console.Write("Press Enter To TerminateÉ"); Console.Read(); } } class Circle { public double area; public double radius; public double pi = 3.14159; public void CalculateCircleArea(string measurementType) { Console.WriteLine("What is the radius of the circle you wish to measure?"); radius = Convert.ToDouble(Console.ReadLine()); area = pi * (Math.sqrt(radius)); Console.WriteLine("The area of the circle is " + area + " " + measurementType + "squared"); Console.Write("Press Enter To TerminateÉ"); Console.Read(); } } class Ellipse { public double area; public double height; public double width; public double pi = 3.14159; public void CalculateEllipseArea(string measurementType) { Console.WriteLine("What is the height of the ellipse you are attempting to measure?"); radius = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("What is the width of the ellipse you are attempting to measure?"); width = pi * width * height; Console.WriteLine("The area of the ellipse is " + area + " " + measurementType + "squared"); Console.Write("Press Enter To TerminateÉ"); Console.Read(); } } class Program { static void Main(string[] args) { int selectionValue; string typeOfMeasurement; Console.WrtieLine("The program will allow you to calculate the area of several plane shapes.\n\nPress 1 to calculate the area of a triangle\nPress 2 to calculate the area of a square\nPress 3 to calculate the area of a triangle\nPress 4 to calculate the area of a pareallelogram\nPress 5 to calculate the area of a circle\nPress 7 to calculate the area of an ellipse.\n\nEnter your selection:"); selectionValue = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Would you like to calculate the measurement in inches or feet?"); typeOfMeasurement = Convert.ToString(Console.ReadLine()); if (selectionValue == 1) { Triangle triangle = new Triangle(); triangle.CalculateTriangleArea(typeOfMeasurement); } else if (selectionValue == 2) { Square square = new Square(); square.CalculateSquareArea(typeOfMeasurement); } else if (selectionValue == 3) { Square square = new Rectangle(); rectangle.CalculateRectangleArea(typeOfMeasurement); } else if (selectionValue == 4) { Parallelogram parallelogram = new Paralleologram(); paralleogram.CalculateParalleogramArea(typeOfMeasurement); } else if (selectionValue == 5) { Trapezoid trapezoid = new Trapezoid(); trapezoid.CalculateTrapezoidArea(typeOfMeasurement); } else if (selectionValue == 6) { Circle circle = new Circle(); circle.CalculateCircleArea(typeOfMeasurement); } else if (selectionValue == 7) { Ellipse ellipse = new Ellipse(); ellipse.CalculateEllipseArea(typeOfMeasurment); } else { Console.WriteLine("You did not enter a valid selection value."); Console.WriteLine("Press any key to terminateÉ"); Console.Read(); } } } }