grach

2D Rectangle Area

Jul 7th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 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 _2D_Rectangle_Area
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             double x1 = Double.Parse(Console.ReadLine());
  15.             Double y1 = Double.Parse(Console.ReadLine());
  16.             Double x2 = Double.Parse(Console.ReadLine());
  17.             Double y2 = Double.Parse(Console.ReadLine());
  18.  
  19.             Double width = Math.Max(x1, x2) - Math.Min(x1, x2);
  20.             Double height = Math.Max(y1, y2) - Math.Min(y1, y2);
  21.  
  22.             Console.WriteLine("area= {0}", width * height);
  23.             Console.WriteLine("perimeter={0}", 2 * (width + height));
  24.  
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment