Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _07._Area_of_Figures
- {
- class Program
- {
- static void Main(string[] args)
- {
- string type = Console.ReadLine();
- double area = 0; //лицето на фигурата
- //проверка за вид: square, rectangle, triangle, circle
- if (type == "square")
- {
- //квадрат
- double a = double.Parse(Console.ReadLine());
- area = a * a;
- }
- else if (type == "rectangle")
- {
- //правоъгълник
- double width = double.Parse(Console.ReadLine());
- double length = double.Parse(Console.ReadLine());
- area = width * length;
- }
- else if (type == "triangle")
- {
- //триъгълник
- double b = double.Parse(Console.ReadLine());
- double h = double.Parse(Console.ReadLine());
- area = b * h / 2;
- }
- else if (type == "circle")
- {
- //кръг
- double r = double.Parse(Console.ReadLine());
- area = Math.PI * r * r;
- }
- Console.WriteLine($"{area:F3}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment