logo image

C# program to calculate trapezoid circumference

33


Following program shows you how to calculate trapezoid circumference. This program gets trapezoid bases and sides from user and calculates circumference and prints it using following formula Circumference = base1 + base2 + side1 +side2

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 side1 of trapezoid:");
    double trapezoidSide1  = Convert.ToDouble(Console.ReadLine());

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

double circumferenceOfTrapezoid = trapezoidBase1 + trapezoidBase2 + trapezoidSide1 + trapezoidSide2;
    Console.WriteLine("Circumference of trapezoid is: " + circumferenceOfTrapezoid);

  }
}

Output:

Please enter base1 of trapezoid:
 12
Please enter base2 of trapezoid:
 16
Please enter side1 of trapezoid:
 18
Please enter side2 of trapezoid:
 20
Circumference of trapezoid is: 66