VladoG

PB - Simple Calculations - 07. 2D Rectangle Area

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