grach

AreaOfFigures

Jul 11th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 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 Area_of_Figures
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             string name = Console.ReadLine();
  15.            
  16.  
  17.             //string b = Console.ReadLine();
  18.  
  19.  
  20.             if (name == "square")
  21.             {
  22.                 var a = double.Parse(Console.ReadLine());
  23.                 Console.WriteLine("square");
  24.                 Console.WriteLine(Math.Round(a*a,3)) ;
  25.             }
  26.  
  27.             else if (name == "rectangle")
  28.             {
  29.                 var b = double.Parse(Console.ReadLine());
  30.                 var c = double.Parse(Console.ReadLine());
  31.                 Console.WriteLine("rectangle");
  32.                 Console.WriteLine(Math.Round(b * c,3));
  33.             }
  34.  
  35.             else if (name == "circle")
  36.             {
  37.                 var d = double.Parse(Console.ReadLine());
  38.                 Console.WriteLine("circle");
  39.                 Console.WriteLine(Math.Round(d * d*Math.PI,3));
  40.             }
  41.  
  42.  
  43.             else if (name == "triangle")
  44.             {
  45.                 var e = double.Parse(Console.ReadLine());
  46.                 var f = double.Parse(Console.ReadLine());
  47.                 Console.WriteLine("triangle");
  48.                 Console.WriteLine(Math.Round(e * f/2,3));
  49.             }
  50.  
  51.  
  52.  
  53.  
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment