Advertisement
VyaraG

Trapezoid

Nov 28th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2.  
  3. //Write an expression that calculates trapezoid's area by given sides a and b and height h. Examples:
  4.  
  5. //formula: ((a+b)*h)/2
  6.  
  7. class Trapezoids
  8. {
  9.     static void Main()
  10.     {
  11.         Console.Write("Enter value for one of the trapezoid's bases: ");
  12.         double a = double.Parse(Console.ReadLine()); //double - to calculate numbers with a floating point
  13.         Console.Write("Enter value for the other of the trapezoid's bases: ");
  14.         double b = double.Parse(Console.ReadLine());
  15.         Console.Write ("Enter a value for the height of the trapezoid: ");
  16.         double h = double.Parse(Console.ReadLine());
  17.         double area = ((a + b) * h) / 2;
  18.         Console.WriteLine("The area of the trapezoid is: {0}", area);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement