Advertisement
Kuncavia

AreaOfFigures

Sep 14th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _08.AreaOfFigures
  8. {
  9.     class AreaOfFigures
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string typeOfFigure = Console.ReadLine();
  14.             double a = 0;
  15.             double b = 0;
  16.             double r = 0;
  17.             double h = 0;
  18.             double area = 0;
  19.             if (typeOfFigure == "square")
  20.             {
  21.                 a = double.Parse(Console.ReadLine());
  22.                 area = a * a;
  23.  
  24.             }
  25.             else if (typeOfFigure == "rectangle")
  26.             {
  27.                 a = double.Parse(Console.ReadLine());
  28.                 b = double.Parse(Console.ReadLine());
  29.                 area = a * b;
  30.             }
  31.             else if (typeOfFigure == "circle")
  32.             {
  33.                 r = double.Parse(Console.ReadLine());
  34.                 area = Math.PI * r * r;
  35.             }
  36.             else if (typeOfFigure == "triangle")
  37.             {
  38.                 a = double.Parse(Console.ReadLine());
  39.                 h = double.Parse(Console.ReadLine());
  40.                 area = (a * h) / 2.0;
  41.             }
  42.             Console.WriteLine("{0:f3}", Math.Round(area, 3));
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement