Advertisement
Klaxon

[C# Operators] Rectangle Area

Jul 8th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. // Write an expression that calculates rectangle’s area by given width and height.
  2.  
  3. using System;
  4.  
  5. class RectangleArea
  6. {
  7.     static void Main()
  8.     {
  9.         // Declaring needed variables
  10.         float height;
  11.         float width;
  12.         float area;
  13.  
  14.         // Get the height of the rectangle
  15.         Console.Write("Enter the height of the rectangle: ");
  16.         height = float.Parse(Console.ReadLine());
  17.  
  18.         // Get the width of the rectangle
  19.         Console.Write("Enter the width of the rectangle: ");
  20.         width = float.Parse(Console.ReadLine());
  21.  
  22.         // Calculates the area of the rectangle
  23.         area = width * height;
  24.  
  25.         // Print on the console
  26.         Console.WriteLine("The area of the rectangle is: {0}", area);
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement