Advertisement
mzografski

Rectangles

Mar 15th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 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. class Rectangles
  8. {
  9.     static void Main()
  10.     {
  11.         //Perimeter = 2(h+w); Area = w*h;
  12.         float rectWidth, rectHeight;
  13.  
  14.         Console.WriteLine("Please, enter rectangle width:");
  15.         while (!float.TryParse(Console.ReadLine(), out rectWidth))
  16.         {
  17.             Console.WriteLine("\nPlease, enter correct width.\n");
  18.         }
  19.         Console.WriteLine("Please, enter rectangle height:");
  20.         while (!float.TryParse(Console.ReadLine(), out rectHeight))
  21.         {
  22.             Console.WriteLine("\nPlease, enter correct height.\n");
  23.         }
  24.  
  25.         Console.WriteLine("Perimeter: {0}; Area: {1}", 2 * (rectHeight + rectWidth), (rectWidth * rectHeight));
  26.  
  27.         Console.WriteLine("Press any key to exit.");
  28.         Console.ReadKey();
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement