Advertisement
Guest User

Different Areas

a guest
Sep 27th, 2017
207
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 _14_var_areas
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string x = Console.ReadLine();
  14.  
  15.             if (x == "square")
  16.             {
  17.                 float side = float.Parse(Console.ReadLine());
  18.                 Console.WriteLine(Math.Round(side * side, 3));
  19.             }
  20.             else if (x == "rectangle")
  21.             {
  22.                 float side1 = float.Parse(Console.ReadLine());
  23.                 float side2 = float.Parse(Console.ReadLine());
  24.                 Console.WriteLine(Math.Round(side1 * side2, 3));
  25.             }
  26.             else if (x == "circle")
  27.             {
  28.                 float side = float.Parse(Console.ReadLine());
  29.                 Console.WriteLine(Math.Round(Math.PI * side * side, 3));
  30.             }
  31.             else if (x == "triangle")
  32.             {
  33.                 float side1 = float.Parse(Console.ReadLine());
  34.                 float side2 = float.Parse(Console.ReadLine());
  35.                 Console.WriteLine(Math.Round((side1 * side2)/2, 3));
  36.             }
  37.             else
  38.             {
  39.                 Console.WriteLine("wrong input!");
  40.             }              
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement