Advertisement
Guest User

11. Geometry Calculator

a guest
Oct 8th, 2017
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 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 _11.GeometryCalculator
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string type = Console.ReadLine().ToLower();
  14.  
  15.             if (type== "triangle")
  16.             {
  17.                 double side = double.Parse(Console.ReadLine());
  18.                 double height = double.Parse(Console.ReadLine());
  19.                 Triangle(side, height);
  20.             }
  21.  
  22.             else if (type == "square")
  23.             {
  24.                 double side = double.Parse(Console.ReadLine());
  25.                 Square(side);
  26.             }
  27.  
  28.             else if (type == "rectangle")
  29.             {
  30.                 double side = double.Parse(Console.ReadLine());
  31.                 double width = double.Parse(Console.ReadLine());
  32.                 Rectangle(side, width);
  33.             }
  34.  
  35.             else if (type == "circle")
  36.             {
  37.                 double radius = double.Parse(Console.ReadLine());
  38.                 Circle(radius);
  39.             }
  40.         }
  41.  
  42.         static void Circle(double radius)
  43.         {
  44.             Console.WriteLine($"{Math.PI*radius*radius:f2}");
  45.         }
  46.  
  47.         static void Rectangle(double side, double width)
  48.         {
  49.             Console.WriteLine($"{side * width:f2}");
  50.         }
  51.  
  52.         static void Square(double side)
  53.         {
  54.             Console.WriteLine($"{side * side:f2}");
  55.         }
  56.  
  57.         static void Triangle(double side, double height)
  58.         {
  59.             Console.WriteLine($"{(side*height)/2:f2}");
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement