Computer Science, asked by trishagarg908, 16 days ago

Write a program in Java to evaluate the area of a trapezium 1/2*(a+b)*​

Answers

Answered by anindyaadhikari13
4

\texttt{\textsf{\large{\underline{Solution}:}}}

The given problem is solved using language - Java.

import java.util.*;

public class TrapeziumArea{

   public static void main(String s[]){

       Scanner sc=new Scanner(System.in);

       double a,b,h,area;

       System.out.print("Enter length of first parallel side: ");

       a=sc.nextDouble();

       System.out.print("Enter the breadth of other parallel side: ");

       b=sc.nextDouble();

       System.out.print("Enter height: ");

       h=sc.nextDouble();

       area=h*(a+b)/2.0;

       System.out.println("Area of the trapezium is: "+area+" square unit.");

       sc.close();

   }

}

\texttt{\textsf{\large{\underline{Logic}:}}}

  • Accept height and length of two parallel sides as input.
  • Calculate area using formula A = h(a + b)/2.
  • Display the area of the trapezium.

See attachment for output.

Attachments:

anindyaadhikari13: Thanks for the brainliest ^_^
Answered by kamalrajatjoshi94
1

Answer:

Program:-

//To calculate the area of trapezium

import java.util.*;

public class Main

{

public static void main(String args[])

{

Scanner in=new Scanner(System.in);

int a,b,h;

double ar=0;

System.out.println("Enter the length of 1st parallel side:");

a=in.nextInt();

System.out.println("Enter the length of 2nd parallel side:");

b=in.nextInt();

System.out.println("Enter the height of trapezium:");

h=in.nextInt();

ar=1.0/2.0*(a+b)*h;

System.out.println("The area of trapezium="+ar);

}

}

Concept:-

Area of trapezium=1/2*(a+b)*h

Attachments:
Similar questions