Advertisement
veronikaaa86

2D Rectangle Area

Oct 17th, 2017
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         double x1 = double.Parse(Console.ReadLine());
  7.             double y1 = double.Parse(Console.ReadLine());
  8.             double x2 = double.Parse(Console.ReadLine());
  9.             double y2 = double.Parse(Console.ReadLine());
  10.            
  11.             double width = Math.Max(x1, x2) - Math.Min(x1, x2);
  12.             double height = Math.Max(y1, y2) - Math.Min(y1, y2);
  13.            
  14.             Console.WriteLine("Area = " + width * height);
  15.             Console.WriteLine("Perimeter =" + 2 * (width + height));
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement