Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _11.GeometryCalculator
- {
- class StartUp
- {
- static void Main()
- {
- // Choosing the figure
- string typeOfFigure = Console.ReadLine();
- if (typeOfFigure == "triangle")
- {
- double side = double.Parse(Console.ReadLine());
- double height = double.Parse(Console.ReadLine());
- Console.WriteLine($"{GetTriangleArea(side,height):f2}");
- }
- else if (typeOfFigure == "rectangle")
- {
- double width = double.Parse(Console.ReadLine());
- double height = double.Parse(Console.ReadLine());
- Console.WriteLine($"{GetRectangleArea(width,height):f2}");
- }
- else if (typeOfFigure == "square")
- {
- double side = double.Parse(Console.ReadLine());
- Console.WriteLine($"{GetSquareArea(side):f2}");
- }
- else if (typeOfFigure == "circle")
- {
- double radius = double.Parse(Console.ReadLine());
- Console.WriteLine($"{GetCircleArea(radius):f2}");
- }
- }
- // Calculating the area of the triangle.
- public static double GetTriangleArea(double side, double height)
- {
- double triangleArea = side * height / 2;
- return triangleArea;
- }
- // Calculating the area of the rectangle.
- public static double GetRectangleArea(double width,double height)
- {
- double rectangleArea = width * height;
- return rectangleArea;
- }
- // Calculating the area of the square.
- public static double GetSquareArea(double side)
- {
- double areaSquare = side * side;
- return areaSquare;
- }
- // Calculating the area of the circle.
- public static double GetCircleArea(double radius)
- {
- double circleArea = Math.PI * radius * radius;
- return circleArea;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment