and the code itself:
using System;
class Trapezoid
{
static void Main()
{
Console.WriteLine("Please write trapezoid's \"a\" base:");
double a = double.Parse(Console.ReadLine());
Console.WriteLine("Please write trapezoid's \"b\" base:");
double b = double.Parse(Console.ReadLine());
Console.WriteLine("Please write trapezoid's \"h\" height:");
double h = double.Parse(Console.ReadLine());
double area = ((a + b) / 2) * h;
Console.WriteLine("The area of your trapezoid is: {0}",area);
}
}
//////////////////////////////////////////////////////////////////////////////////
You must be very careful with the numeral data type you are using!
For example if you use int instead of double with:
a = 3
b = 4
h = 5
Instead of getting 17.5 for the area of this trapezoid you will get 15 (in the picture below!);
And as you know programming deleting is not like the usual one! ;-)
