Advertisement
Krissy

CSharp_H3_RectangleArea

Nov 12th, 2012
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. class RectangleArea
  5. {
  6.     static void Main()
  7.     {
  8.         Console.WriteLine("Please enter the height of the rectangle.");//Instructions for the user
  9.         double height = double.Parse(Console.ReadLine());
  10.         Console.WriteLine("Please enter the width of the rectangle.");
  11.         double width = double.Parse(Console.ReadLine());
  12.        
  13.         if (height>0 && width>0) //checks if input numbers are positive.
  14.         {
  15.             double rectangleArea = height * width;
  16.             Console.WriteLine("The rectangle area is {0}.", rectangleArea);
  17.         }
  18.         else
  19.         {
  20.             Console.WriteLine("Please enter positive numbers.");
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement