Advertisement
AnitaN

03.OperatorsExpressionsStatements/04.Rectangles

Mar 20th, 2014
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. //Problem 4.    Rectangles
  2. //Write an expression that calculates rectangle’s perimeter and area by given width and height.
  3. using System;
  4.  
  5. class Rectangles
  6. {
  7.     static void Main()
  8.     {
  9.         Console.Write("Please, enter rectangle's width: ");
  10.         double widthRectangle = double.Parse(Console.ReadLine());
  11.         Console.Write("Please, enter rectangle's height:");
  12.         double heightRectangle = double.Parse(Console.ReadLine());
  13.         double perimeterRectangle=2*(widthRectangle+heightRectangle);
  14.         double areaRectangle = widthRectangle * heightRectangle;
  15.         Console.WriteLine("Rectangle's perimeter is {0}.",perimeterRectangle);
  16.         Console.WriteLine("Rectangle's area is {0}.", areaRectangle);
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement