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 areaOfFigures
- {
- class Program
- {
- static void Main(string[] args)
- {
- string typeOfFigure = Console.ReadLine();
- double area = 0.0;
- switch (typeOfFigure)
- {
- case "Square":
- {
- double a = Double.Parse(Console.ReadLine());
- area = a * a;
- break;
- }
- case "Rectangle":
- {
- double a = Double.Parse(Console.ReadLine());
- double b = Double.Parse(Console.ReadLine());
- area = a * b;
- break;
- }
- case "Circle":
- {
- double radius = Double.Parse(Console.ReadLine());
- area = Math.PI * radius * radius;
- break;
- }
- case "Triangle":
- {
- double sideLenght = Double.Parse(Console.ReadLine());
- double hight = Double.Parse(Console.ReadLine());
- area = (sideLenght * hight) / 2;
- break;
- }
- }
- Console.WriteLine($"{area:f3}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement