lmarkov

Rectangle Area

Nov 25th, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2.  
  3. class RectangleArea
  4. {
  5.     static void Main()
  6.     {
  7.         double height, width;
  8.  
  9.         Console.Write("Enter width: ");
  10.         if (double.TryParse(Console.ReadLine(), out width) && width > 0 && width <= double.MaxValue)
  11.         {
  12.             Console.Write("Enter height: ");
  13.             if (double.TryParse(Console.ReadLine(), out height) && height > 0 &&  height <= double.MaxValue)
  14.             {
  15.                 Console.WriteLine("\nRectangle area: {0} * {1} = {2}\n", width, height, width*height);
  16.                 Console.WriteLine("{0}\n", new string('=',40));
  17.                 Main();
  18.             }
  19.             else
  20.             {
  21.                 Console.WriteLine("Please enter value between {0} and {1}\n", 0, double.MaxValue);
  22.                 Main();
  23.             }
  24.         }
  25.         else
  26.         {
  27.             Console.WriteLine("Please enter value between {0} and {1}\n", 0, double.MaxValue);
  28.             Main();
  29.         }
  30.  
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment