Advertisement
desislava_topuzakova

03.2D Rectangle Area

Feb 9th, 2020
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03._2DRectangleArea
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             double x1 = double.Parse(Console.ReadLine());
  11.             double y1 = double.Parse(Console.ReadLine());
  12.             double x2 = double.Parse(Console.ReadLine());
  13.             double y2 = double.Parse(Console.ReadLine());
  14.  
  15.             double length = Math.Abs(x1 - x2);
  16.             double width = Math.Abs(y1 - y2);
  17.             double area = length * width;
  18.             double perimeter = 2 * (length + width);
  19.  
  20.             Console.WriteLine($"{area:F2}");
  21.             Console.WriteLine($"{perimeter:F2}");
  22.  
  23.  
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement