simonakancheva

RectangleCalc

Apr 8th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1.  class Rectangle_Calc
  2.     {
  3.         public double width { get; set; }
  4.  
  5.         public double heigth { get; set; }
  6.  
  7.         public double AreaCalc
  8.         {
  9.             get
  10.             {
  11.                 return width * heigth;
  12.             }
  13.         }
  14.         public double PerimeterCalc
  15.         {
  16.             get
  17.             {
  18.                 return 2 * width + 2 * heigth;
  19.             }
  20.         }
  21.         public double DiagonalCalc
  22.         {
  23.             get
  24.             {
  25.                 return Math.Sqrt(width * width + heigth * heigth);
  26.             }
  27.         }
  28.  
  29.         public override string ToString()
  30.         {
  31.             return string.Format("{0}", AreaCalc);
  32.         }
  33.  
  34.     }
  35.  
  36.  
  37.  
  38.  
  39.  static void Main(string[] args)
  40.         {
  41.             double widthRec = double.Parse(Console.ReadLine());
  42.             double heightRec = double.Parse(Console.ReadLine());
  43.  
  44.             Rectangle_Calc rec = new Rectangle_Calc { width = widthRec, heigth = heightRec };
  45.  
  46.             Console.WriteLine($"Perimater: {rec.PerimeterCalc}");
  47.             Console.WriteLine($"Area: {rec.AreaCalc}");
  48.             Console.WriteLine($"Diagonals: {rec.DiagonalCalc}");
  49.         }
Advertisement
Add Comment
Please, Sign In to add comment