Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _11.GeometryCalculator
- {
- class Program
- {
- static void Main(string[] args)
- {
- string type = Console.ReadLine().ToLower();
- if (type== "triangle")
- {
- double side = double.Parse(Console.ReadLine());
- double height = double.Parse(Console.ReadLine());
- Triangle(side, height);
- }
- else if (type == "square")
- {
- double side = double.Parse(Console.ReadLine());
- Square(side);
- }
- else if (type == "rectangle")
- {
- double side = double.Parse(Console.ReadLine());
- double width = double.Parse(Console.ReadLine());
- Rectangle(side, width);
- }
- else if (type == "circle")
- {
- double radius = double.Parse(Console.ReadLine());
- Circle(radius);
- }
- }
- static void Circle(double radius)
- {
- Console.WriteLine($"{Math.PI*radius*radius:f2}");
- }
- static void Rectangle(double side, double width)
- {
- Console.WriteLine($"{side * width:f2}");
- }
- static void Square(double side)
- {
- Console.WriteLine($"{side * side:f2}");
- }
- static void Triangle(double side, double height)
- {
- Console.WriteLine($"{(side*height)/2:f2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement