FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 54   



Following program shows you how to calculate trapezoid area.
This program gets trapezoid base and height from user and calculates area and prints it using following formula
Area = (base1 + base2) X height /2

using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine("Please enter base1 of trapezoid:");
    double trapezoidBase1 = Convert.ToDouble(Console.ReadLine());

    Console.WriteLine("Please enter base2 of trapezoid:");
    double trapezoidBase2  = Convert.ToDouble(Console.ReadLine());

    Console.WriteLine("Please enter height  of trapezoid:");
    double trapezoidHeight  = Convert.ToDouble(Console.ReadLine());

    double areaOfTrapezoid = (trapezoidBase1 + trapezoidBase2) * trapezoidHeight / 2;
    Console.WriteLine("Area of trapezoid is: " + areaOfTrapezoid);

  }
}

Output:

Please enter base1 of trapezoid:
 12
Please enter base2 of trapezoid:
 16
Please enter height  of trapezoid:
 18
Area of trapezoid is: 252



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News