Advertisement
braveheart1989

RectangleProperties

May 22nd, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 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 _12.RectangleProperties
  8. {
  9.     class Rectangle_Calc
  10.     {
  11.         public double width { get; set; }
  12.  
  13.         public double heigth { get; set; }
  14.  
  15.         public double AreaCalc
  16.         {
  17.             get
  18.             {
  19.                 return width * heigth;
  20.             }
  21.         }
  22.         public double PerimeterCalc
  23.         {
  24.             get
  25.             {
  26.                 return 2 * width + 2 * heigth;
  27.             }
  28.         }
  29.         public double DiagonalCalc
  30.         {
  31.             get
  32.             {
  33.                 return Math.Sqrt(width * width + heigth * heigth);
  34.             }
  35.         }
  36.  
  37.         public override string ToString()
  38.         {
  39.             return string.Format("{0}", AreaCalc);
  40.         }
  41.  
  42.     }
  43.  
  44.     class RectangleProperties
  45.     {
  46.         static void Main(string[] args)
  47.         {
  48.             double widthRec = double.Parse(Console.ReadLine());
  49.             double heightRec = double.Parse(Console.ReadLine());
  50.  
  51.             Rectangle_Calc rec = new Rectangle_Calc { width = widthRec,heigth=heightRec };
  52.  
  53.             Console.WriteLine(rec.PerimeterCalc);
  54.             Console.WriteLine(rec.AreaCalc);
  55.             Console.WriteLine(rec.DiagonalCalc);
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement